I'd like to be able to get all the key-values stored in a Berkeley DB using the Ruby bindings from http://github.com/mattbauer/bdb/tree/master but I'm not sure how to proceed. Any pointers will be appreciated.
UPDATE
Here's a small script that loops over the keys and prints them. Based on Pax' answer:
require 'rubygems'
require 'bdb'
env = Bdb::Env.new(0)
env.open('foo', Bdb::DB_CREATE,0)
db = env.db
db.open(nil, 'db1.db', nil, Bdb::Db::BTREE, Bdb::DB_CREATE,0)
db.put(nil, 'key', 'value', 0)
db.put(nil, 'key1', 'value1', 0)
db.put(nil, 'key2', 'value2', 0)
dbc = db.cursor(nil,0)
key,val = dbc.get(nil,nil,Bdb::DB_FIRST)
while key
p key,val
key,val = dbc.get(nil,nil,Bdb::DB_NEXT)
end
dbc.close
db.close(0)
env.close