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
This commit is contained in:
Matt Riedemann 2014-03-03 10:31:52 -08:00
parent 21fcdad0f4
commit 12a6bcfa8c
1 changed files with 11 additions and 3 deletions

View File

@ -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.