python database access dbm-style database modules python includes number of library modules for supporting unix dbm-style database files several standard types of these databases are supported the dbm module is used to read standard unix-dbm database files the gdbm module is used to read gnu dbm database files (to read database files created by the berkeley db library (database/berkeley-db/index htmlthe dumbdbm module is pure-python module that implements simple dbm-style database on its own all of these modules provide an object that implements persistent string-based dictionary that isit works like python dictionary except that all keys and values are restricted to strings database file is typically opened using variation of the open(function open(filename [flag [mode]]this function opens the database file filename and returns database object flag is 'rfor read-only access'wfor read-write access'cto create the database if it doesn' existor 'nto force the creation of new database mode is the integer fileaccess mode used when creating the database (the default is on unixthe object returned by the open(function minimally supports the following dictionary-like operationsoperation description [keyvalue value [keydel [keyd close(key in sync(inserts value into the database gets data from the database removes database entry closes the database tests for key writes all changes out to the database specific implementations may also add additional features (consult the appropriate module reference for detailsone issue with the various dbm-style database modules is that not every module is installed on every platform for exampleif you use python on windowsthe dbm and gdbm modules are typically unavailable howevera program may still want to create dbm-style database for its own use to address this issuepython provides module anydbm that can be used to open and create dbm-style database file this module provides an open(function as described previouslybut it is guaranteed to work on all platforms it does this by looking at the set of available dbm modules and picking the most advanced library that is available (typically dbhash if it' installedas fallbackit uses the dumbdbm module which is always available another module is whichdbwhich has function whichdb(filenamethat can be used to probe file in order to determine what kind of dbm-database created it as general ruleit is probably best not to rely upon these low-level modules for any application where portability is important for exampleif you create dbm database on one machine and then transfer the database file to another machinethere is chance that python won' be able to read it if the underlying dbm module isn' lib fl ff