dynamically import

Skip Montanaro skip at pobox.com
Fri Jan 31 14:12:17 CET 2003


    Reid> How can I have a database connection depending on different DBI
    Reid> 2.0 module dynamically?

You mean like this:

    try:
        import MySQLdb
        DB = "MySQL"
        ...
    except ImportError:
        import psycopg
        DB = "PostgreSQL"
        ...

?

Skip





More information about the Python-list mailing list