whichdb

The whichdb module provides a function that attempts to guess which of the several simple database modules (dbm, gdbm, or dbhash) should be used to open a database file.

whichdb(filename)

filename is a filename without any suffixes. Returns None if the file cannot be opened because it’s unreadable or doesn’t exist. Returns the empty string if the file format cannot be guessed. Otherwise, a string containing the required module name is returned, such as ‘dbm’ or ‘gdbm’.

See Also

anydbm (p. 238)

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.