Refactor db commands to use sqltools library