[DB-SIG] BSDDB What now!
Magnus Lycka
magnus@thinkware.se
Wed, 05 Feb 2003 11:30:04 +0100
At 20:15 2003-02-05 +1100, Duane Hennessy wrote:
> Does anybody know where I can find the information to use BSDDB with
>Python?
See
http://www.python.org/doc/current/lib/module-bsddb.html
and
http://www.python.org/doc/current/lib/module-anydbm.html
In brief you use it as a python dictionary. You have to
use a special constructor where you supply the file name
and maybe some other parameters, instead of just doing
db = {} as you would with a dict. After that you basically
treat it as a dictionary, and your data will magically persist.
The database will be created when you open it the first
time. There is nothing like a database schema or anything
like that. A simple db[key] = value will create/update a
record.
I have a little warning, although it might not be an issue
with recent versions: If you open a database and don't store
any data, an empty file will be created. Next time you try
to open it, you will get an error, since it's not recognized
as a database file. But maybe that's fixed by now. It's been
some time since I used it.
--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se