class Connector(object):
pass
-
from . import Connector
+
class MxODBCConnector(Connector):
- driver='mxodbc'
+ driver = 'mxodbc'
supports_sane_multi_rowcount = False
supports_unicode_statements = True
elif platform == 'darwin':
from mx.ODBC import iODBC as module
else:
- raise ImportError, "Unrecognized platform for mxODBC import"
+ raise ImportError("Unrecognized platform for mxODBC import")
return module
@classmethod
emit Python standard warnings.
"""
from mx.ODBC.Error import Warning as MxOdbcWarning
- def error_handler(connection, cursor, errorclass, errorvalue):
+ def error_handler(connection, cursor, errorclass, errorvalue):
if issubclass(errorclass, MxOdbcWarning):
errorclass.__bases__ = (Warning,)
warnings.warn(message=str(errorvalue),
return True
def do_executemany(self, cursor, statement, parameters, context=None):
- cursor.executemany(statement, parameters, direct=self._get_direct(context))
+ cursor.executemany(
+ statement, parameters, direct=self._get_direct(context))
def do_execute(self, cursor, statement, parameters, context=None):
cursor.execute(statement, parameters, direct=self._get_direct(context))
from .. import exc, log, schema, sql, types as sqltypes, util, processors
import re
+
# the subclassing of Connector by all classes
# here is not strictly necessary
+
class MySQLDBExecutionContext(Connector):
@property
else:
return self.cursor.rowcount
+
class MySQLDBCompiler(Connector):
def visit_mod_binary(self, binary, operator, **kw):
return self.process(binary.left, **kw) + " %% " + \
def post_process_text(self, text):
return text.replace('%', '%%')
+
class MySQLDBIdentifierPreparer(Connector):
def _escape_identifier(self, value):
value = value.replace(self.escape_quote, self.escape_to_quote)
return value.replace("%", "%%")
+
class MySQLDBConnector(Connector):
driver = 'mysqldb'
supports_unicode_statements = False
# query string.
ssl = {}
- for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']:
+ keys = ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']
+ for key in keys:
if key in opts:
ssl[key[4:]] = opts[key]
util.coerce_kw_type(ssl, key[4:], str)
"combination of MySQL server and MySQL-python. "
"MySQL-python >= 1.2.2 is recommended. Assuming latin1.")
return 'latin1'
-
import re
import urllib
+
class PyODBCConnector(Connector):
- driver='pyodbc'
+ driver = 'pyodbc'
supports_sane_multi_rowcount = False
# PyODBC unicode is broken on UCS-4 builds
dsn_connection = 'dsn' in keys or \
('host' in keys and 'database' not in keys)
if dsn_connection:
- connectors= ['dsn=%s' % (keys.pop('host', '') or \
+ connectors = ['dsn=%s' % (keys.pop('host', '') or \
keys.pop('dsn', ''))]
else:
port = ''
connectors = ["DRIVER={%s}" %
keys.pop('driver', self.pyodbc_driver_name),
'Server=%s%s' % (keys.pop('host', ''), port),
- 'Database=%s' % keys.pop('database', '') ]
+ 'Database=%s' % keys.pop('database', '')]
user = keys.pop("user", None)
if user:
connectors.append("AutoTranslate=%s" %
keys.pop("odbc_autotranslate"))
- connectors.extend(['%s=%s' % (k,v) for k,v in keys.iteritems()])
- return [[";".join (connectors)], connect_args]
+ connectors.extend(['%s=%s' % (k, v) for k, v in keys.iteritems()])
+ return [[";".join(connectors)], connect_args]
def is_disconnect(self, e, connection, cursor):
if isinstance(e, self.dbapi.ProgrammingError):
))
if self.freetds:
- self.freetds_driver_version = dbapi_con.getinfo(pyodbc.SQL_DRIVER_VER)
+ self.freetds_driver_version = dbapi_con.getinfo(
+ pyodbc.SQL_DRIVER_VER)
# the "Py2K only" part here is theoretical.
# have not tried pyodbc + python3.1 yet.
# Py2K
- self.supports_unicode_statements = not self.freetds and not self.easysoft
+ self.supports_unicode_statements = (
+ not self.freetds and not self.easysoft)
if self._user_supports_unicode_binds is not None:
self.supports_unicode_binds = self._user_supports_unicode_binds
else:
- self.supports_unicode_binds = (not self.freetds or
- self.freetds_driver_version >= '0.91'
- ) and not self.easysoft
+ self.supports_unicode_binds = (
+ not self.freetds or self.freetds_driver_version >= '0.91'
+ ) and not self.easysoft
# end Py2K
# run other initialization which asks for user name, etc.
import sys
from . import Connector
+
class ZxJDBCConnector(Connector):
driver = 'zxjdbc'