Fix database acccess

The database access layer has been fixed to always use SqlAlchemy
for connection pooling and sessions.