Skip to content

Instantly share code, notes, and snippets.

@dw

dw/demo.py

Created May 5, 2016
Embed
What would you like to do?
import lmdb
def test():
env = lmdb.open("test.lmdb", max_dbs=1, map_size=15*1024*1024)
try:
value = bytearray(" "*9*1024*1024)
with env.begin(write=True, buffers=True) as txn:
txn.put("big", value, dupdata=False, overwrite=True)
with env.begin(write=True,) as txn:
print txn.delete("big")
with env.begin(write=True,) as txn:
txn.put('a', 'a')
with env.begin(write=True, buffers=True) as txn:
txn.put("big", value, dupdata=False, overwrite=True)
with env.begin(write=True,) as txn:
print txn.delete("big")
with env.begin(write=True,) as txn:
txn.put('a', 'a')
finally:
env.sync()
env.close()
#import pdb;pdb.set_trace()
if __name__ == "__main__":
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment