From 2cd55d842f41d3f9f7b5dcf03c9c4a5e0a6be709 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Wed, 24 Feb 2021 08:51:55 -0700 Subject: [PATCH] mssql+pyodbc specify ampersand separator Specify that ampersand (not semicolon) must be used to separate additional keyword arguments in hostname connections. Change-Id: Id5b3276e6da8d42f5384e3cc4f5272f6e20aa61c --- lib/sqlalchemy/dialects/mssql/pyodbc.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index c94b506788..4c1e9e1160 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -53,9 +53,18 @@ name must be URL encoded which means using plus signs for spaces:: Other keywords interpreted by the Pyodbc dialect to be passed to ``pyodbc.connect()`` in both the DSN and hostname cases include: ``odbc_autotranslate``, ``ansi``, ``unicode_results``, ``autocommit``, -``authentication`` (e.g., ``authentication=ActiveDirectoryIntegrated``). +``authentication``. Note that in order for the dialect to recognize these keywords (including the ``driver`` keyword above) they must be all lowercase. +Multiple additional keyword arguments must be separated by an +ampersand (``&``), not a semicolon: + + engine = create_engine( + "mssql+pyodbc://scott:tiger@myhost:port/databasename" + "?driver=ODBC+Driver+17+for+SQL+Server" + "&authentication=ActiveDirectoryIntegrated" + ) + Pass through exact Pyodbc string ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- 2.47.3