Skip to content

Commit

Permalink
Tidy setting db
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Jun 11, 2024
1 parent f16ba00 commit d70fc3a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions abcd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d70fc3a

Please sign in to comment.