下面内容段是关于LevelDB的Python开发包 py-leveldb基本使用方法的内容,希望能对码农们有帮助。
import leveldb
db = leveldb.LevelDB(’./db’)
single put
db.Put(‘hello’, ‘world’)
print db.Get(‘hello’)
single delete
db.Delete(‘hello’)
print db.Get(‘hello’)
multiple put/delete applied atomically, and committed to disk
batch = leveldb.WriteBatch()
batch.Put(‘hello’, ‘world’)
batch.Put(‘hello again’, ‘world’)
batch.Delete(‘hello’)
db.Write(batch, sync = True)