示例#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])
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)
示例#3
0
def initialize_database(database_file, pragmas=None):
    database.init(database_file, pragmas=pragmas)
    try:
        meth = database.execution_context
    except AttributeError:
        meth = database

    with meth:
        database.create_tables(
            [Attachment, BlobData, Document, Index, IndexDocument, Metadata])