summaryrefslogtreecommitdiffstats
path: root/openstack/common/db/sqlalchemy
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-02-04 16:24:10 +0000
committerMark McLoughlin <markmc@redhat.com>2013-02-07 15:25:29 -0500
commit131075abb9691c204ef74bd108123d5e5fa9b9b7 (patch)
treebd0f051302ab6a4be594776371d863c9319cae10 /openstack/common/db/sqlalchemy
parentf895ca35ee029bc730b06657f3a6451086a19c58 (diff)
downloadoslo-131075abb9691c204ef74bd108123d5e5fa9b9b7.tar.gz
oslo-131075abb9691c204ef74bd108123d5e5fa9b9b7.tar.xz
oslo-131075abb9691c204ef74bd108123d5e5fa9b9b7.zip
Use importutils.try_import() for MySQLdb
This is a common pattern we've adopted elsewhere, so use it here too. Change-Id: I2e0947b4857005b478e796e9c9a7c05ea1f0d926
Diffstat (limited to 'openstack/common/db/sqlalchemy')
-rw-r--r--openstack/common/db/sqlalchemy/session.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py
index 2c714b1..c6aeae6 100644
--- a/openstack/common/db/sqlalchemy/session.py
+++ b/openstack/common/db/sqlalchemy/session.py
@@ -246,12 +246,6 @@ import time
from eventlet import db_pool
from eventlet import greenthread
-try:
- import MySQLdb
- from MySQLdb.constants import CLIENT as mysql_client_constants
-except ImportError:
- MySQLdb = None
- mysql_client_constants = None
from sqlalchemy.exc import DisconnectionError, OperationalError, IntegrityError
import sqlalchemy.interfaces
import sqlalchemy.orm
@@ -259,10 +253,14 @@ from sqlalchemy.pool import NullPool, StaticPool
from sqlalchemy.sql.expression import literal_column
from openstack.common import cfg
+from openstack.common import importutils
from openstack.common import log as logging
from openstack.common.gettextutils import _
from openstack.common import timeutils
+MySQLdb = importutils.try_import('MySQLdb')
+if MySQLdb is not None:
+ from MySQLdb.constants import CLIENT as mysql_client_constants
sql_opts = [
cfg.StrOpt('sql_connection',