The whichdb module

This module can be used to figure out which database handler that was used for a given database file.

Example: Using the whichdb module
# File:

import whichdb

filename = "database"

result = whichdb.whichdb(filename)

if result:
    print "file created by", result
    handler = __import__(result)
    db =, "r")
    print db.keys()
    # cannot identify data base
    if result is None:
        print "cannot read database file", filename
        print "cannot identify database file", filename
    db = None

This example used the __import__ function to import a module with the given name.


A Django site. rendered by a django application. hosted by webfaction.