mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 22:16:37 +00:00
Use a filter map to make maintenance easier
A possible future improvement would be to define a map of which keys Connection accepts. Right now, this is removing keys after Connection fails because of an unknown key. This could be automated by using try and removing a key each time the exception is caught.
This commit is contained in:
parent
21e9cbef4b
commit
7b033d6e62
@ -26,9 +26,12 @@ class DatabaseWrapper(base.DatabaseWrapper):
|
||||
|
||||
|
||||
def get_new_connection(self, conn_params):
|
||||
filtered_params = conn_params.copy()
|
||||
filtered_params["isolation_level"] = filtered_params.pop("transaction_mode", "DEFERRED")
|
||||
_ = filtered_params.pop("init_command", None)
|
||||
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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user