dynamically import
Mike Zamansky
zamansky at groo.stuy.edu
Sat Feb 1 16:15:20 EST 2003
More information about the Python-list mailing list
Sat Feb 1 16:15:20 EST 2003
- Previous message (by thread): Setting a Global Default for class construction?
- Next message (by thread): metaclass confusions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Reid Lai <reidlai at reidlai.com> writes: > Dear All, > > How can I have a database connection depending on different DBI 2.0 > module dynamically? What I want is like following: > > a = "DBVendor" > > if DBVendor == "PostgreSQL": > from pyPgSQL import PgSQL > connfactory = PgSQL > elsif DBVendor == "Oracle": > from DCOracle2 import * > connfactory = DCOracle2 > You could do somethign like the following: my_module=__import__(module_name) then later, you can use it: x=my_module.functionname(etc) Mike
- Previous message (by thread): Setting a Global Default for class construction?
- Next message (by thread): metaclass confusions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list