Skip to content

Commit

Permalink
Add SUPPORTED_BACKENDS strategy (closes encode#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhadam committed Sep 23, 2021
1 parent 612857d commit 3c9772a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion databases/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(

self._force_rollback = force_rollback

backend_str = self.SUPPORTED_BACKENDS[self.url.scheme]
backend_str = self._get_backend()
backend_cls = import_from_string(backend_str)
assert issubclass(backend_cls, DatabaseBackend)
self._backend = backend_cls(self.url, **self.options)
Expand Down Expand Up @@ -329,6 +329,13 @@ def _build_query(

return query

def _get_backend(self) -> Optional[str]:
try:
return self.SUPPORTED_BACKENDS[self.url.scheme]
except KeyError:
return self.SUPPORTED_BACKENDS[self.url.dialect]



class Transaction:
def __init__(
Expand Down

0 comments on commit 3c9772a

Please sign in to comment.