Refactor db commands to use sqltools library

addresses #920