Get all keys?

1,583 views
Skip to first unread message

Shuhao

unread,
Feb 25, 2013, 9:27:35 PM2/25/13
to py-le...@googlegroups.com
Is it possible to list all keys in a db?

Thanks,
Shuhao

Árni Már Jónsson

unread,
Feb 26, 2013, 11:07:02 AM2/26/13
to py-le...@googlegroups.com
Hi,

One way is with an unbounded iterator. You can pass it a flag s.t. it only returns keys, otherwise it returns a (key, value) 2-tuple.

import leveldb

db = leveldb.LevelDB('./db')

db.Put('hello', 'value')
db.Put('world', 'value')

for k in db.RangeIter(include_value = False):
print 'K', k

Regards, Árni Már


--
You received this message because you are subscribed to the Google Groups "py-leveldb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py-leveldb+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Shuhao

unread,
Mar 5, 2013, 5:46:05 PM3/5/13
to py-le...@googlegroups.com
Thanks very much!
Reply all
Reply to author
Forward
0 new messages