1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# http://code.google.com/p/py-leveldb/ # install subversion sudo apt-get install -y subversion # get source code from SVN mkdir -p ~/build/py-leveldb-read cd ~/build/py-leveldb-read svn checkout http://py-leveldb.googlecode.com/svn/trunk/ py-leveldb-read-only cd py-leveldb-read-only # build the leveldb library ./compile_leveldb.sh # build the Python extensions python setup.py build # install it sudo python setup.py install python -c 'import leveldb; print "works"' #cd leveldb-read-only #make #cd .. #sudo python setup.py install |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
mkdir -p ~/build/leveldb/ cd ~/build/leveldb/ sudo apt-get install -y git libsnappy-dev git clone https://code.google.com/p/leveldb/ cd leveldb #cd ~/build/leveldb/leveldb make # You don't neccessarily need snappy as LevelDB will work without it but you would need to recompile if you don't install it before compiling. # Installation: Excecute the following shell snippet as root from your LevelDB folder: #!/bin/sh sudo cp --preserve=links libleveldb.* /usr/local/lib sudo cp -r include/leveldb /usr/local/include/ sudo ldconfig ########## cpy-leveldb########### # doesn't work mkdir -p ~/build/leveldb cd ~/build/leveldb git clone https://github.com/forhappy/cpy-leveldb cd cpy-leveldb sudo python setup.py install |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
mkdir -p ~/build/leveldb/test cd ~/build/leveldb/test tee ./leveldb_test.py <<"_EOF_" import leveldb db = leveldb.LevelDB("./testlevel.db") print "put", db.Put('hello', 'world') print "get", db.Get('hello') print "delete", db.Delete('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') print "batch write", db.Write(batch, sync = True) _EOF_ python leveldb_test.py put None get world delete None batch write None |