Skip to content

Commit

Permalink
feat: allow specifying the mongodb database name
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdh committed Sep 17, 2024
1 parent 6275dbb commit b99ee96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dataimporter/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __init__(self, config: Config):
self.config = config
# client for mongo and elasticsearch via Splitgill
self.client = SplitgillClient(
config.get_mongo_client(), config.get_elasticsearch_client()
config.get_mongo_client(),
config.get_elasticsearch_client(),
config.get_mongo_database_name(),
)

# make sure the data path exists
Expand Down
4 changes: 4 additions & 0 deletions dataimporter/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_client(self) -> Elasticsearch:
class MongoConfig:
host: str = "localhost"
port: int = 27017
database: str = "sg"

def get_client(self) -> MongoClient:
return MongoClient(self.host, self.port)
Expand Down Expand Up @@ -60,6 +61,9 @@ def get_elasticsearch_client(self) -> Elasticsearch:
def get_mongo_client(self) -> MongoClient:
return self.mongo_config.get_client()

def get_mongo_database_name(self) -> str:
return self.mongo_config.database


class ConfigLoadError(Exception):
def __init__(self, reason: str):
Expand Down

0 comments on commit b99ee96

Please sign in to comment.