环境安装

【环境安装】

ubuntu20.04

1)编译leveldb

参考https://blog.csdn.net/weixin_29294975/article/details/116928909

#wget https://github.com/google/leveldb/archive/v1.19.zip

git clone https://github.com/google/leveldb.git

git checkout -b v1.19 tags/v1.19

make

cd out-shared/

sudo mv libleveldb.* /usr/local/lib

cd ../include/

sudo cp -R leveldb /usr/local/include

ldconfig

2)安装python相关

apt autoremove python3

apt install -y python2 unzip python-dev

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py

python2 get-pip.py

pip2 install leveldb

【测试代码】

python testLevel.py

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)

 【代码量】

posted @ 2022-03-27 00:31  stupidstan2019  阅读(27)  评论(0编辑  收藏  举报