Move some database functions from Main to Database, and abstract the connection pool runner