From: Mike Bayer Date: Fri, 28 Oct 2022 05:49:03 +0000 (-0400) Subject: mssql doc updates X-Git-Tag: rel_2_0_0b3~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c262184ae5bac969b18eff8e10ba6d94c229499d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git mssql doc updates clarify some URL things Change-Id: Ic162834052f06fd3a6c010ce5d091903fdc65cd8 --- diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 09b4a80b6e..3b8caef3b0 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -51,18 +51,18 @@ name must be URL encoded which means using plus signs for spaces:: engine = create_engine("mssql+pyodbc://scott:tiger@myhost:port/databasename?driver=ODBC+Driver+17+for+SQL+Server") -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``. -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:49242/databasename" - "?driver=ODBC+Driver+17+for+SQL+Server" +The ``driver`` keyword is significant to the pyodbc dialect and must be +specified in lowercase. + +Any other names passed in the query string are passed through in the pyodbc +connect string, such as ``authentication``, ``TrustServerCertificate``, etc. +Multiple keyword arguments must be separated by an ampersand (``&``); these +will be translated to semicolons when the pyodbc connect string is generated +internally:: + + e = create_engine( + "mssql+pyodbc://scott:tiger@mssql2017:1433/test?" + "driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes" "&authentication=ActiveDirectoryIntegrated" ) @@ -73,11 +73,12 @@ The equivalent URL can be constructed using :class:`_sa.engine.URL`:: "mssql+pyodbc", username="scott", password="tiger", - host="myhost", - port=49242, - database="databasename", + host="mssql2017", + port=1433, + database="test", query={ - "driver": "ODBC Driver 17 for SQL Server", + "driver": "ODBC Driver 18 for SQL Server", + "TrustServerCertificate": "yes", "authentication": "ActiveDirectoryIntegrated", }, )