Make tornado.database importable when MySQLdb is not available.
This fixes the docs build on readthedocs.org. Closes #485.
This commit is contained in:
parent
2ff579a65c
commit
38908bf6b7
|
@ -19,13 +19,19 @@
|
||||||
from __future__ import absolute_import, division, with_statement
|
from __future__ import absolute_import, division, with_statement
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import MySQLdb.constants
|
|
||||||
import MySQLdb.converters
|
|
||||||
import MySQLdb.cursors
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
try:
|
||||||
|
import MySQLdb.constants
|
||||||
|
import MySQLdb.converters
|
||||||
|
import MySQLdb.cursors
|
||||||
|
except ImportError:
|
||||||
|
# If MySQLdb isn't available this module won't actually be useable,
|
||||||
|
# but we want it to at least be importable (mainly for readthedocs.org,
|
||||||
|
# which has limitations on third-party modules)
|
||||||
|
MySQLdb = None
|
||||||
|
|
||||||
class Connection(object):
|
class Connection(object):
|
||||||
"""A lightweight wrapper around MySQLdb DB-API connections.
|
"""A lightweight wrapper around MySQLdb DB-API connections.
|
||||||
|
@ -213,7 +219,7 @@ class Row(dict):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise AttributeError(name)
|
raise AttributeError(name)
|
||||||
|
|
||||||
|
if MySQLdb is not None:
|
||||||
# Fix the access conversions to properly recognize unicode/binary
|
# Fix the access conversions to properly recognize unicode/binary
|
||||||
FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
|
FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
|
||||||
FLAG = MySQLdb.constants.FLAG
|
FLAG = MySQLdb.constants.FLAG
|
||||||
|
|
Loading…
Reference in New Issue