reformat code to use Sqlite database, built pseudo ORM for interacting with db