From: Michael Trier Date: Mon, 10 Nov 2008 04:29:53 +0000 (+0000) Subject: Handle the mssql port properly. If we're using the SQL Server driver then use the... X-Git-Tag: rel_0_5rc4~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=306bee4ecd1ddcab860f9b39866b2f57b6ec509a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Handle the mssql port properly. If we're using the SQL Server driver then use the correct host,port syntax, otherwise use the Port= parameter in the connection string. Fixes #1192. --- diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index b254941ab2..a313b98bce 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -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)