Rewrote the db interface to use sqlalchemy and simplify interaction with the scheduler.