Move DB imports out of module-level

DAOFactory gets imported by different CRAB bits, but that's bad if
the three dialects aren't loaded in SQLAlchemy. Push this inside the
module
Merge pull request #4858 from PerilousApricot/bugfix/realign-imports

Move DB imports out of module-level