From 45ff8cb1e6021b957fb9836d0f2e2bcf91ddb844 Mon Sep 17 00:00:00 2001 From: Tim Reichard Date: Fri, 20 Oct 2023 10:26:27 -0500 Subject: [PATCH] Add TrustServerCertificate option in sqlserver connection string --- HISTORY.rst | 5 +++++ aioradio/pyodbc.py | 4 ++++ setup.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index dbe5f1d..797950a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ======= +v0.19.3 (2023-10-20) + +* Add TrustServerCertificate option in sqlserver connection string, enabling use of driver {ODBC Driver 18 for SQL Server}. + + v0.19.2 (2023-10-19) * Add new DB_CONNECT class that uses env vars instead of AWS secret manager for sensitive creds. diff --git a/aioradio/pyodbc.py b/aioradio/pyodbc.py index 782b2ed..6392ad9 100644 --- a/aioradio/pyodbc.py +++ b/aioradio/pyodbc.py @@ -49,6 +49,7 @@ def establish_pyodbc_connection( database: str='', tds_version: str='7.4', trusted_connection: str='', + trust_server_certificate: str='', multi_subnet_failover: str='', driver: str='', application_intent: str='', @@ -65,6 +66,7 @@ def establish_pyodbc_connection( database (str, optional): database. Defaults to ''. tds_version (str, optional): TDS_Version. Defaults to '7.4'. trusted_connection (str, optional): Trusted_Connection. Defaults to ''. + trust_server_certificate (str, optional): TrustServerCertificate. Defaults to ''. multi_subnet_failover (str, optional): MultiSubnetFailover. Defaults to ''. driver (str, optional): unixodbc driver. Defaults to ''. application_intent (str, optional): ReadOnly | ReadWrite. Defaults to ''. @@ -98,6 +100,8 @@ def establish_pyodbc_connection( conn_string += f';MultiSubnetFailover={multi_subnet_failover}' if application_intent: conn_string += f';ApplicationIntent={application_intent}' + if trust_server_certificate: + conn_string += f';TrustServerCertificate={trust_server_certificate}' return pyodbc.connect(conn_string, autocommit=autocommit) diff --git a/setup.py b/setup.py index 3d7f23e..e0386fb 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = fileobj.read() setup(name='aioradio', - version='0.19.2', + version='0.19.3', description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more', long_description=long_description, long_description_content_type="text/markdown",