Reputation: 5768
I would like to drop an lmdb database. The following hits 'typerror:invalid type' on the txn.drop(db_name) line.
import lmdb
def kill_db(db_name):
print('ABOUT TO DELETE DB '+str(db_name)+'!!!!')
raw_input('press enter to continue or ctrl-C to not')
env = lmdb.open(db_name, readonly=False)
txn = lmdb.Transaction(env)
txn.drop(db_name)
any clues as to why this is happening? I am new to lmdb (as you may have guessed) so be gentle.
Upvotes: 2
Views: 2160
Reputation: 153
Maybe this helps you:
import lmdb
def kill_db(db_name):
print('ABOUT TO DELETE DB '+str(db_name)+'!!!!')
raw_input('press enter to continue or ctrl-C to not')
in_db = lmdb.open(db_name)
with in_db.begin(write=True) as in_txn:
db = in_db.open_db()
in_txn.drop(db)
print in_txn.stat()
You can find a documentation here: https://lmdb.readthedocs.org/en/release/
Another way, if you want to completely remove the LMDB from your disk, you could also just use:
import os
import shutil
if os.path.exists(db_name):
shutil.rmtree(db_name)
Upvotes: 1