Exemplo n.º 1
0
 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])
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
 def close_database(exc):
     if database.database != ':memory:' and not database.is_closed():
         database.close()