]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Handle the mssql port properly. If we're using the SQL Server driver then use the...
authorMichael Trier <mtrier@gmail.com>
Mon, 10 Nov 2008 04:29:53 +0000 (04:29 +0000)
committerMichael Trier <mtrier@gmail.com>
Mon, 10 Nov 2008 04:29:53 +0000 (04:29 +0000)
lib/sqlalchemy/databases/mssql.py

index b254941ab2aa7956734bbc8cf813d8513ec13680..a313b98bce1de24f7512d5cc202ed2aa6bedf4fa 100644 (file)
@@ -797,12 +797,18 @@ class MSSQLDialect_pyodbc(MSSQLDialect):
         if 'dsn' in keys:
             connectors = ['dsn=%s' % keys.pop('dsn')]
         else:
+            port = ''
+            if 'port' in keys and (
+                keys.get('driver', 'SQL Server') == 'SQL Server'):
+                port = ',%d' % int(keys.pop('port'))
+
             connectors = ["DRIVER={%s}" % keys.pop('driver', 'SQL Server'),
-                          'Server=%s' % keys.pop('host', ''),
+                          'Server=%s%s' % (keys.pop('host', ''), port),
                           'Database=%s' % keys.pop('database', '') ]
-            if 'port' in keys:
+
+            if 'port' in keys and not port:
                 connectors.append('Port=%d' % int(keys.pop('port')))
-        
+
         user = keys.pop("user", None)
         if user:
             connectors.append("UID=%s" % user)