From d70fc3accfaba93d0963900d96ecdb6c599e3c99 Mon Sep 17 00:00:00 2001 From: ElliottKasoar <45317199+ElliottKasoar@users.noreply.github.com> Date: Tue, 11 Jun 2024 14:01:06 +0100 Subject: [PATCH] Tidy setting db --- abcd/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/abcd/__init__.py b/abcd/__init__.py index 54358239..70f8cdc9 100644 --- a/abcd/__init__.py +++ b/abcd/__init__.py @@ -24,6 +24,9 @@ def from_url(cls, url, **kwargs): r = parse.urlparse(url) logger.info(r) + db = r.path.split("/")[1] if r.path else None + db = db if db else "abcd" + if ConnectionType[r.scheme] is ConnectionType.mongodb: conn_settings = { "host": r.hostname, @@ -33,9 +36,6 @@ def from_url(cls, url, **kwargs): "authSource": "admin", } - db = r.path.split("/")[1] if r.path else None - db = db if db else "abcd" - from abcd.backends.atoms_pymongo import MongoDatabase return MongoDatabase(db_name=db, **conn_settings, **kwargs) @@ -48,9 +48,6 @@ def from_url(cls, url, **kwargs): "password": r.password, } - db = r.path.split("/")[1] if r.path else None - db = db if db else "abcd" - from abcd.backends.atoms_opensearch import OpenSearchDatabase return OpenSearchDatabase(db=db, **conn_settings, **kwargs)