Update tornado
This commit is contained in:
Regular → Executable
+27
-18
@@ -16,14 +16,24 @@
|
||||
|
||||
"""A lightweight wrapper around MySQLdb."""
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
import copy
|
||||
import MySQLdb.constants
|
||||
import MySQLdb.converters
|
||||
import MySQLdb.cursors
|
||||
import itertools
|
||||
import logging
|
||||
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):
|
||||
"""A lightweight wrapper around MySQLdb DB-API connections.
|
||||
|
||||
@@ -41,7 +51,7 @@ class Connection(object):
|
||||
UTF-8 on all connections to avoid time zone and encoding errors.
|
||||
"""
|
||||
def __init__(self, host, database, user=None, password=None,
|
||||
max_idle_time=7*3600):
|
||||
max_idle_time=7 * 3600):
|
||||
self.host = host
|
||||
self.database = database
|
||||
self.max_idle_time = max_idle_time
|
||||
@@ -210,20 +220,19 @@ class Row(dict):
|
||||
except KeyError:
|
||||
raise AttributeError(name)
|
||||
|
||||
if MySQLdb is not None:
|
||||
# Fix the access conversions to properly recognize unicode/binary
|
||||
FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
|
||||
FLAG = MySQLdb.constants.FLAG
|
||||
CONVERSIONS = copy.copy(MySQLdb.converters.conversions)
|
||||
|
||||
# Fix the access conversions to properly recognize unicode/binary
|
||||
FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
|
||||
FLAG = MySQLdb.constants.FLAG
|
||||
CONVERSIONS = copy.copy(MySQLdb.converters.conversions)
|
||||
field_types = [FIELD_TYPE.BLOB, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]
|
||||
if 'VARCHAR' in vars(FIELD_TYPE):
|
||||
field_types.append(FIELD_TYPE.VARCHAR)
|
||||
|
||||
field_types = [FIELD_TYPE.BLOB, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]
|
||||
if 'VARCHAR' in vars(FIELD_TYPE):
|
||||
field_types.append(FIELD_TYPE.VARCHAR)
|
||||
for field_type in field_types:
|
||||
CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
|
||||
|
||||
for field_type in field_types:
|
||||
CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
|
||||
|
||||
|
||||
# Alias some common MySQL exceptions
|
||||
IntegrityError = MySQLdb.IntegrityError
|
||||
OperationalError = MySQLdb.OperationalError
|
||||
# Alias some common MySQL exceptions
|
||||
IntegrityError = MySQLdb.IntegrityError
|
||||
OperationalError = MySQLdb.OperationalError
|
||||
|
||||
Reference in New Issue
Block a user