dbm — Unix 数据库接口

源代码: Lib/dbm/__init__.py


dbm is a generic interface to variants of the DBM database:

If none of these modules are installed, the slow-but-simple implementation in module dbm.dumb will be used. There is a third party interface to the Oracle Berkeley DB.

exception dbm. error

A tuple containing the exceptions that can be raised by each of the supported modules, with a unique exception also named dbm.error as the first item — the latter is used when dbm.error 被引发。

dbm. whichdb ( filename )

This function attempts to guess which of the several simple database modules available — dbm.sqlite3 , dbm.gnu , dbm.ndbm ,或 dbm.dumb — should be used to open a given file.

Return one of the following values:

  • None if the file can’t be opened because it’s unreadable or doesn’t exist

  • the empty string ( '' ) if the file’s format can’t be guessed

  • a string containing the required module name, such as 'dbm.ndbm' or 'dbm.gnu'

3.11 版改变: filename accepts a 像路径对象 .