Skip to content

Commit b99ee96

Browse files
committed
feat: allow specifying the mongodb database name
1 parent 6275dbb commit b99ee96

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

dataimporter/importer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def __init__(self, config: Config):
6363
self.config = config
6464
# client for mongo and elasticsearch via Splitgill
6565
self.client = SplitgillClient(
66-
config.get_mongo_client(), config.get_elasticsearch_client()
66+
config.get_mongo_client(),
67+
config.get_elasticsearch_client(),
68+
config.get_mongo_database_name(),
6769
)
6870

6971
# make sure the data path exists

dataimporter/lib/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def get_client(self) -> Elasticsearch:
1919
class MongoConfig:
2020
host: str = "localhost"
2121
port: int = 27017
22+
database: str = "sg"
2223

2324
def get_client(self) -> MongoClient:
2425
return MongoClient(self.host, self.port)
@@ -60,6 +61,9 @@ def get_elasticsearch_client(self) -> Elasticsearch:
6061
def get_mongo_client(self) -> MongoClient:
6162
return self.mongo_config.get_client()
6263

64+
def get_mongo_database_name(self) -> str:
65+
return self.mongo_config.database
66+
6367

6468
class ConfigLoadError(Exception):
6569
def __init__(self, reason: str):

0 commit comments

Comments
 (0)