The aim of bw_projects is relatively simple - we want to store data in a SQLite file and in a few subdirectories, and we want to be able to do switch this SQLite file and associated subdirectories whenever we want.
To do this we use peewee as an ORM to SQLite, and its ability to bind ORM tables to a database object after initial import:
def _create_database(self):
db = SqliteDatabase(self._filepath)
for model in self._tables:
model.bind(db, bind_refs=False, bind_backrefs=False)
db.connect()