Skip to content

Commit

Permalink
Separate the backend and test connection options
Browse files Browse the repository at this point in the history
As the options passed to a full backend (connection pool) are unlikely
to be the same as those passed to a connection. This therefore allows
both without causing an error as before.
  • Loading branch information
pgjones committed Dec 15, 2024
1 parent ba11280 commit 24d625f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/quart_db/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def create_app():
is acquired and placed on g for each request.
backend_options: Options to pass directly to the backend
engines. Will depend on the backend used.
test_connection_options: Options to pass directly to the
connection used for testing. Will depend on the
backend used.
state_table_name: The name of the table used to store the
migration status.
"""
Expand All @@ -77,6 +80,7 @@ def __init__(
data_path: Optional[str] = None,
auto_request_connection: bool = True,
backend_options: Optional[Dict[str, Any]] = None,
test_connection_options: Optional[Dict[str, Any]] = None,
migration_timeout: Optional[float] = None,
state_table_name: Optional[str] = None,
) -> None:
Expand All @@ -85,6 +89,9 @@ def __init__(
self._backend_options = backend_options
if self._backend_options is None:
self._backend_options = {}
self._test_connection_options = test_connection_options
if self._test_connection_options is None:
self._test_connection_options = {}
self._backend: Optional[BackendABC] = None
self._type_converters: TypeConverters = defaultdict(dict)
self._migrations_folder = migrations_folder
Expand Down Expand Up @@ -261,7 +268,7 @@ def _create_backend(self) -> BackendABC:
raise ValueError(f"{scheme} is not a supported backend")

if self._testing:
return TestingBackend(url, self._backend_options, self._type_converters)
return TestingBackend(url, self._test_connection_options, self._type_converters)
else:
return Backend(url, self._backend_options, self._type_converters)

Expand Down

0 comments on commit 24d625f

Please sign in to comment.