From: Mike Bayer Date: Sun, 26 Nov 2023 15:02:47 +0000 (-0500) Subject: add MARS connection for aioodbc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3434f1539aa9d71ff229aefeb2414191afd92ae7;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git add MARS connection for aioodbc on jenkins main we are getting a lot of connection busy with other results, which we assume is due to the thread-pool based approach of aioodbc not being very solid. MARS is described at: https://stackoverflow.com/questions/9017264/why-only-some-users-get-the-error-connection-is-busy-with-results-for-another https://learn.microsoft.com/en-us/sql/relational-databases/native-client/features/using-multiple-active-result-sets-mars?view=sql-server-ver16 not clear why the name of the parameter is different in those two articles. using a totally made up parameter doesn't raise any error, so it's not clear if this works at all. Change-Id: I8e437e9f46c1c070c5102a24d7d82a912e8b5145 --- diff --git a/lib/sqlalchemy/dialects/mssql/provision.py b/lib/sqlalchemy/dialects/mssql/provision.py index 096ae03fa5..2db3ee44f0 100644 --- a/lib/sqlalchemy/dialects/mssql/provision.py +++ b/lib/sqlalchemy/dialects/mssql/provision.py @@ -29,6 +29,9 @@ def generate_driver_url(url, driver, query_str): if driver not in ("pyodbc", "aioodbc"): new_url = new_url.set(query="") + if driver == "aioodbc": + new_url = new_url.update_query_dict({"MARS_Connection": "Yes"}) + if query_str: new_url = new_url.update_query_string(query_str) @@ -37,6 +40,7 @@ def generate_driver_url(url, driver, query_str): except exc.NoSuchModuleError: return None else: + print(f"NEW URL!!!!! {new_url}") return new_url