Made it work with postgresql instead of sqlite3.