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)
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)
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))
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)
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)
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")
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...')
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()
def destroy(db_dir: str = DIR) -> None: destroy_db(db_dir)
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)
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)
def destroy_store(self): self.close() plyvel.destroy_db(self._path)
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)
def db_setup(): if to_empty_db: plyvel.destroy_db(db_connection_name) return plyvel.DB(db_connection_name, create_if_missing=True)