rewrite db interface, use internal global db now to make full use of database/sql's connection pool