{
    "mode": "pydoc",
    "parameter": "dbm",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/dbm/json",
    "generated": "2026-06-02T15:52:05Z",
    "sections": {
        "NAME": {
            "content": "dbm - Generic interface to all dbm clones.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/dbm.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Use\n\nimport dbm\nd = dbm.open(file, 'w', 0o666)\n\nThe returned object is a dbm.gnu, dbm.ndbm or dbm.dumb object, dependent on the\ntype of database being opened (determined by the whichdb function) in the case\nof an existing dbm. If the dbm does not exist and the create or new flag ('c'\nor 'n') was specified, the dbm type will be determined by the availability of\nthe modules (tested in the above order).\n\nIt has the following interface (key and data are strings):\n\nd[key] = data   # store data at key (may override data at\n# existing key)\ndata = d[key]   # retrieve data at key (raise KeyError if no\n# such key)\ndel d[key]      # delete data stored at key (raises KeyError\n# if no such key)\nflag = key in d # true if the key exists\nlist = d.keys() # return a list of all existing keys (slow!)\n\nFuture versions may change the order in which implementations are\ntested for existence, and add interfaces to other dbm-like\nimplementations.\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "dumb\ngnu\nndbm\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "open",
                    "content": "Open or create database at path given by *file*.\n\nOptional argument *flag* can be 'r' (default) for read-only access, 'w'\nfor read-write access of an existing database, 'c' for read-write access\nto a new or existing database, and 'n' for read-write access to a new\ndatabase.\n\nNote: 'r' and 'w' fail if the database doesn't exist; 'c' creates it\nonly if it doesn't exist; and 'n' always creates a new database.\n"
                },
                {
                    "name": "whichdb",
                    "content": "Guess which db package to use to open a db file.\n\nReturn values:\n\n- None if the database file can't be read;\n- empty string if the file can be read but can't be recognized\n- the name of the dbm submodule (e.g. \"ndbm\" or \"gnu\") if recognized.\n\nImporting the given module may still fail, and opening the\ndatabase using that module may still fail.\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['open', 'whichdb', 'error']\nerror = (<class 'dbm.error'>, <class 'OSError'>)\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/dbm/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "dbm - Generic interface to all dbm clones.",
    "flags": [],
    "examples": [],
    "see_also": []
}