Commits

paj  committed b3d28c9

can now specify a DSN for PyODBC, ticket #724

  • Participants
  • Parent commits 37c8ea6
  • Branches rel_0_3

Comments (0)

Files changed (2)

     - 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

File lib/sqlalchemy/databases/mssql.py

 
     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)