diff options
author | Matt Riedemann <mriedem@us.ibm.com> | 2014-03-03 10:31:52 -0800 |
---|---|---|
committer | Matt Riedemann <mriedem@us.ibm.com> | 2014-03-04 10:12:40 -0800 |
commit | 12a6bcfa8c1ead90f22135ea7ab75352ed06d6b2 (patch) | |
tree | 0053f2045f21f0da585a30e245cc9b06b561d8b5 | |
parent | 21fcdad0f485437d010e5743626c63ab3acdaec5 (diff) | |
download | sqalchemy-migrate-12a6bcfa8c1ead90f22135ea7ab75352ed06d6b2.tar.gz |
Conditionally import ibmdb2/ibm_db_sa
Since ibm_db_sa is not part of sqlalchemy, we need to handle the
conditional import of the module in visitor.py so we don't get an
ImportError if ibm_db_sa is not available.
Closes-Bug: #1287229
Change-Id: Ida070b629ce3b9be727ae49973bb6a71543c1dcf
-rw-r--r-- | migrate/changeset/databases/visitor.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/migrate/changeset/databases/visitor.py b/migrate/changeset/databases/visitor.py index 224c40f..c70aa6b 100644 --- a/migrate/changeset/databases/visitor.py +++ b/migrate/changeset/databases/visitor.py @@ -8,8 +8,7 @@ from migrate.changeset.databases import (sqlite, postgres, mysql, oracle, - firebird, - ibmdb2) + firebird) # Map SA dialects to the corresponding Migrate extensions @@ -21,10 +20,19 @@ DIALECTS = { "mysql": mysql.MySQLDialect, "oracle": oracle.OracleDialect, "firebird": firebird.FBDialect, - "ibm_db_sa": ibmdb2.IBMDBDialect } +# NOTE(mriedem): We have to conditionally check for DB2 in case ibm_db_sa +# isn't available since ibm_db_sa is not packaged in sqlalchemy like the +# other dialects. +try: + from migrate.changeset.databases import ibmdb2 + DIALECTS["ibm_db_sa"] = ibmdb2.IBMDBDialect +except ImportError: + pass + + def get_engine_visitor(engine, name): """ Get the visitor implementation for the given database engine. |