]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
can now specify a DSN for PyODBC, ticket #724
authorPaul Johnston <paj@pajhome.org.uk>
Fri, 17 Aug 2007 17:58:55 +0000 (17:58 +0000)
committerPaul Johnston <paj@pajhome.org.uk>
Fri, 17 Aug 2007 17:58:55 +0000 (17:58 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py

diff --git a/CHANGES b/CHANGES
index 983cd1dc75a1c498511db5ee1e01b7931e42f10f..a5827782e84c0f7e7b531fe4c57c0caab4b730d3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,7 @@
     - added support for BIGINT, MONEY, SMALLMONEY, UNIQUEIDENTIFIER and 
       SQL_VARIANT [ticket:721]
     - index names are now quoted when dropping from reflected tables [ticket:684]
+    - can now specify a DSN for PyODBC, using a URI like mssql:///?dsn=bob
 - postgres
     - when reflecting tables from alternate schemas, the "default" placed upon
       the primary key, i.e. usually a sequence name, has the "schema" name
index 72aef8f4674c2c072ad24a77480b546cd12ad4b4..d64fe926a754812cae71b516b2d7736ba25ff007 100644 (file)
@@ -758,15 +758,19 @@ class MSSQLDialect_pyodbc(MSSQLDialect):
 
     def supports_unicode_statements(self):
         """indicate whether the DBAPI can receive SQL statements as Python unicode strings"""
+        # PyODBC unicode is broken on UCS-4 builds
         return sys.maxunicode == 65535
 
     def make_connect_string(self, keys):
-        connectors = ["Driver={SQL Server}"]
-        if 'port' in keys:
-            connectors.append('Server=%s,%d' % (keys.get('host'), keys.get('port')))
+        if 'dsn' in keys:
+            connectors = ['dsn=%s' % keys['dsn']]
         else:
-            connectors.append('Server=%s' % keys.get('host'))
-        connectors.append("Database=%s" % keys.get("database"))
+            connectors = ["Driver={SQL Server}"]
+            if 'port' in keys:
+                connectors.append('Server=%s,%d' % (keys.get('host'), keys.get('port')))
+            else:
+                connectors.append('Server=%s' % keys.get('host'))
+            connectors.append("Database=%s" % keys.get("database"))
         user = keys.get("user")
         if user:
             connectors.append("UID=%s" % user)