Unify db abstraction to enable using SQLite as well as PostgreSQL