]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add MARS connection for aioodbc
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 26 Nov 2023 15:02:47 +0000 (10:02 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 26 Nov 2023 15:06:47 +0000 (10:06 -0500)
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

lib/sqlalchemy/dialects/mssql/provision.py

index 096ae03fa5698e2b1ab6aa7dfcbbac37d1484eee..2db3ee44f014ad17a623994d07a9a9fd72c64f4b 100644 (file)
@@ -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