[英]how can I iterate through all keys with python and leveldb
I want to use python's leveldb bindings to store data. 我想使用python的leveldb绑定来存储数据。 I don't see in any of the docs how to iterate through all the keys without knowing them ahead of time. 我没有在任何文档中看到如何在不提前知道所有键的情况下迭代所有键。 I see it is possible in the C bindings from this page: https://rawgit.com/google/leveldb/master/doc/index.html 我看到此页面的C绑定中有可能: https : //rawgit.com/google/leveldb/master/doc/index.html
leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) {
cout << it->key().ToString() << ": " << it->value().ToString() << endl;
}
assert(it->status().ok()); // Check for any errors found during the scan
delete it;
How can I do this from within python? 我如何从python中做到这一点?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.