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"
)
"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",
},
)