From 32dead212689f2127e33b7932f01b21c50bb4d7e Mon Sep 17 00:00:00 2001 From: tcely Date: Thu, 12 Dec 2024 10:35:46 -0500 Subject: [PATCH] Proof of concept for automated param removal --- tubesync/tubesync/sqlite3/base.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tubesync/tubesync/sqlite3/base.py b/tubesync/tubesync/sqlite3/base.py index b2d10a20..7e9e5f57 100644 --- a/tubesync/tubesync/sqlite3/base.py +++ b/tubesync/tubesync/sqlite3/base.py @@ -27,11 +27,24 @@ class DatabaseWrapper(base.DatabaseWrapper): def get_new_connection(self, conn_params): filter_map = { - "init_command": None, "transaction_mode": ("isolation_level", "DEFERRED"), } filtered_params = {k: v for (k,v) in conn_params.items() if k not in filter_map} filtered_params.update({v[0]: conn_params.get(k, v[1]) for (k,v) in filter_map.items() if v is not None}) - return super().get_new_connection(filtered_params) + + attempt = 0 + connection = None + tries = len(filtered_params) + while connection is None and attempt < tries: + try: + attempt += 1 + connection = super().get_new_connection(filtered_params) + except TypeError as e: + # remove unaccepted param + print(e, flush=True) + print('Exception args:', flush=True) + print(e.args, flush=True) + del filtered_params["init_command"] + return connection