Example code for anydbm wanted...

Skip Montanaro skip at pobox.com
Sun Aug 3 22:05:34 EDT 2003


    John> Does anyone have any good example code that shows how to use the
    John> "anydbm" wrapper tp interface with a very simple database.  like
    John> some examples of how to use "dumbdbm"?  Then perhaps at a later
    John> time, I'm going to want to then interface it to a more robust
    John> database like PostGreSQL or mySQL.  But I want to external
    John> interface to "hide" the specifics and have a really generic
    John> interface.

The anydbm module and the modules it wraps (dumbdbm, bsddb, dbm and gdbm)
are really persistent dictionaries, not true databases.  They offer no query
capabilities beyond searching for specific keys and provide few, if any, of
the features you would expect from a database (SQL, transactions,
multi-threading, etc).  If what you will eventually want is a relational
database like PostgreSQL or MySQL, then take a look at the DB API Spec, aka
PE 249:

    http://www.python.org/peps/pep-0249.html

and choose a relational database to use.

Skip





More information about the Python-list mailing list