summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/connectors/pyodbc.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-17 13:14:47 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-17 13:14:47 -0400
commitb81e9741ba26f2740725c9d403d116284af7d7a4 (patch)
tree5b8792ceca125ac46e8055db997ce9e6e82bba11 /lib/sqlalchemy/connectors/pyodbc.py
parent893f6563730f4d2460dd266a8fea40a38c678794 (diff)
downloadsqlalchemy-b81e9741ba26f2740725c9d403d116284af7d7a4.tar.gz
- basic sybase+pyodbc support. in particular this will impact freetds detection for MS-SQL as well.
Diffstat (limited to 'lib/sqlalchemy/connectors/pyodbc.py')
-rw-r--r--lib/sqlalchemy/connectors/pyodbc.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sqlalchemy/connectors/pyodbc.py b/lib/sqlalchemy/connectors/pyodbc.py
index ce8e84c33..e503135f7 100644
--- a/lib/sqlalchemy/connectors/pyodbc.py
+++ b/lib/sqlalchemy/connectors/pyodbc.py
@@ -19,6 +19,10 @@ class PyODBCConnector(Connector):
# hold the desired driver name
pyodbc_driver_name = None
+ # will be set to True after initialize()
+ # if the freetds.so is detected
+ freetds = False
+
@classmethod
def dbapi(cls):
return __import__('pyodbc')
@@ -76,6 +80,26 @@ class PyODBCConnector(Connector):
else:
return False
+ def initialize(self, connection):
+ # determine FreeTDS first. can't issue SQL easily
+ # without getting unicode_statements/binds set up.
+
+ pyodbc = self.dbapi
+
+ dbapi_con = connection.connection
+
+ self.freetds = bool(re.match(r".*libtdsodbc.*\.so", dbapi_con.getinfo(pyodbc.SQL_DRIVER_NAME)))
+
+ # the "Py2K only" part here is theoretical.
+ # have not tried pyodbc + python3.1 yet.
+ # Py2K
+ self.supports_unicode_statements = not self.freetds
+ self.supports_unicode_binds = not self.freetds
+ # end Py2K
+
+ # run other initialization which asks for user name, etc.
+ super(PyODBCConnector, self).initialize(connection)
+
def _get_server_version_info(self, connection):
dbapi_con = connection.connection
version = []