Skip to content

Commit fafd6ee

Browse files
committed
mssql_script: use kwargs to pass encryption/tds_version only when not None, update changelog
1 parent 2643137 commit fafd6ee

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- mssql_script - adds ``tds_version`` and ``encryption`` parameters for pymssql (https://github.com/ansible-collections/community.general/pull/10816).

plugins/modules/mssql_script.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
type: bool
6363
default: false
6464
version_added: 8.4.0
65+
encryption:
66+
description:
67+
- Specify whether to use encryption for the connection to the server, Please refer to the pymssql documentation for detailed information.
68+
type: str
69+
tds_version:
70+
description:
71+
- Specify the TDS protocol version to use when connecting to the server, Please refer to the pymssql documentation for detailed information.
72+
type: str
6573
output:
6674
description:
6775
- With V(default) each row is returned as a list of values. See RV(query_results).
@@ -330,8 +338,17 @@ def run_module():
330338
msg="when supplying login_user argument, login_password must also be provided")
331339

332340
try:
333-
conn = pymssql.connect(
334-
user=login_user, password=login_password, host=login_querystring, database=db, encryption=encryption, tds_version=tds_version)
341+
kwargs = {
342+
"user": login_user,
343+
"password": login_password,
344+
"host": login_querystring,
345+
"database": db,
346+
}
347+
if encryption is not None:
348+
kwargs["encryption"] = encryption
349+
if tds_version is not None:
350+
kwargs["tds_version"] = tds_version
351+
conn = pymssql.connect(**kwargs)
335352
cursor = conn.cursor()
336353
except Exception as e:
337354
if "Unknown database" in str(e):

0 commit comments

Comments
 (0)