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.
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’.
anydbm (p. 238)