def setUp(self): if not database.is_closed(): database.close() database.connect() assert database.get_tables() == [] database.create_tables( [Attachment, BlobData, Document, Metadata, Index, IndexDocument])
def init_db(reset_database=False): """Create and/or initialize database""" if not database.is_closed(): database.close() database.init(DB_CONFIG['DATABASE'], pragmas=DB_CONFIG['PRAGMAS']) database.connect() if reset_database: database.drop_tables(_TABLES, safe=True) database.create_tables(_TABLES)
def connect_database(): if database.database != ':memory:': database.connect()