uhm i'm trying to make a very simple but large database:
Let's say I want these fields : |name|age|country|
Then I can't do this because I use the same key
db["name"] = 'piet' db["age"] = '20' db["country"] = 'nl' # same keys so it wil overwrite db["name"] = 'jan' db["age"] = '40' db["country"] = 'eng'
But how does other people use bsddb then ? - with a hidden |int like below ?
db["name|0"] = 'jan' db["age|1"] = '40' db["country|2"] = 'eng'
- do a little math to first is name sec is age third is country
db["0"] = 'jan' db["1"] = '40' db["2"] = 'eng'
pointer=0 for k, v in db.items(): if pointer =3: poiner = 0 #next 3 fields
---------------------- I like bsddb because of the speed and it can handle big files, but what is the normal way of using it ?
I don't know about normal but I'd probably do something like
db['piet'] = repr(['piet', 20, 'nl'])
or maybe
db['jan'] = repr({"name":'jan', "age":40, "country":'eng'})
That should hold until Piet #2 comes along, then I might add another level of lists...
With more complicated data I'd do as the docs say and take a look at marshal or pickle instead of using repr(). And use a class instead of lists or dicts...
/ug -- http://mail.python.org/mailman/listinfo/python-list