Пример #1
0
 def __init__(self, name="./db/levelrec-test", init=True):
     if init:
         try:
             plyvel.destroy_db(name)
         except:
             pass
     self.db = plyvel.DB(name, create_if_missing=True)
Пример #2
0
def _clear_yesterday(now):
    global lvl_db_map

    yes_root = path.expanduser(_root_date(now - ONEDAY_Delta))
    yes_db = lvl_db_map.pop(yes_root, None)
    if yes_db:
        yes_db.close()
        plyvel.destroy_db(yes_root)
Пример #3
0
 def destroy_db(self):
     try:
         from plyvel import destroy_db
     except ImportError:
         raise ImportError("LevelDB requires the plyvel \
                            library which is not available for import.")
     self.db.close()
     destroy_db(str(self.db_path))
Пример #4
0
def test_destroy_db(db_dir):
    db_dir = os.path.join(db_dir, 'subdir')
    db = plyvel.DB(db_dir, create_if_missing=True)
    db.put(b'foo', b'bar')
    db.close()
    del db

    plyvel.destroy_db(db_dir)
    assert not os.path.lexists(db_dir)
Пример #5
0
def test_destroy_db():
    with tmp_db('destroy', create=False, delete=False) as name:
        db = DB(name, create_if_missing=True)
        db.put(b'foo', b'bar')
        db.close()
        del db

        plyvel.destroy_db(name)
        assert not os.path.lexists(name)
Пример #6
0
def test_destroy_db(db_dir):
    db_dir = os.path.join(db_dir, 'subdir')
    db = plyvel.DB(db_dir, create_if_missing=True)
    db.put(b'foo', b'bar')
    db.close()
    del db

    plyvel.destroy_db(db_dir)
    assert not os.path.lexists(db_dir)
Пример #7
0
def db():
    plyvel.destroy_db("./taskdb")
    db = plyvel.DB("../taskdb", create_if_missing=True)
    tasks = (Todo("Buy bananas",
                  "High"), Todo("Read new Batman comic", done=True),
             Todo("Schedule doctor appointment", "Low"))
    for task in tasks:
        db.put(bytes(task.description, encoding='utf-8'), pickle.dumps(task))
    yield db
    db.close()
    plyvel.destroy_db("../taskdb")
Пример #8
0
def destroy():
    """ close all databases dir """
    tables = config['database']['tables']
    logger.info('leveldb drop all databases ' + str(tables))
    for table in tables:
        if table is not None:
            try:
                dir = config['database']['path'] + table + '/'
                l.destroy_db(dir)
            except:
                # print(table + ' is not exist')
                continue
    logger.info('leveldb destroy...')
Пример #9
0
 def clear(self):
     logging.info('clearing all data')
     self.closeDatabases()
     plyvel.destroy_db(self.databasePath + '/mdbSM')
     plyvel.destroy_db(self.databasePath + '/mdbMS')
     plyvel.destroy_db(self.databasePath + '/mdbAnnotation')
     self.openDatabases()
Пример #10
0
def destroy(db_dir: str = DIR) -> None:
    destroy_db(db_dir)
Пример #11
0
 def destroy(self):
     """Erase the hypergraph."""
     self.db.close()
     plyvel.destroy_db(self.dir_path)
     self.db = plyvel.DB(self.dir_path, create_if_missing=True)
Пример #12
0
 def __truncatedb(self, dbname):
     plyvel.destroy_db(self.__dbpath + '/' + dbname)
def destroy_db(database_name):
    """
    Delete database_name database.
    """
    print('Database destroyed.\n')
    plyvel.destroy_db(database_name)
Пример #14
0
 def destroy_store(self):
     self.close()
     plyvel.destroy_db(self._path)
Пример #15
0
 def clearAnnotationDB(self):
     logging.info('clearing annotation database')
     if self.dbAnnotation is not None:
         self.dbAnnotation.close()
     plyvel.destroy_db(self.databasePath + '/mdbAnnotation')
     self.dbAnnotation = plyvel.DB(self.databasePath + '/mdbAnnotation', create_if_missing=True)
Пример #16
0
 def db_setup():
     if to_empty_db:
         plyvel.destroy_db(db_connection_name)
     return plyvel.DB(db_connection_name, create_if_missing=True)