Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee746ec

Browse files
committed
Allow specifying non-local mongodb
Fix:#87
1 parentb25c9ca commitee746ec

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

‎docs/src/configuration.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ To use non-default databases, perform the following steps:
6666

6767
# only the chosen db's config will be read
6868
mongodb:
69+
'uri': 'mongodb://127.0.0.1:27017/'
6970
'db': 'repo'
7071
'collection': 'data'
7172

‎ndn_python_repo/ndn-python-repo.conf.sample‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ db_config:
1717
leveldb:
1818
'dir': '~/.ndn/ndn-python-repo/leveldb/' # directory to leveldb database files
1919
mongodb:
20+
'uri': 'mongodb://127.0.0.1:27017/'
2021
'db': 'repo'
2122
'collection': 'data'
2223

‎ndn_python_repo/storage/mongodb.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
classMongoDBStorage(Storage):
99

10-
def__init__(self,db:str,collection:str):
10+
def__init__(self,db:str,collection:str,uri:str='mongodb://127.0.0.1:27017/'):
1111
"""
1212
Init a MongoDB storage with unique index on key.
1313
@@ -17,7 +17,7 @@ def __init__(self, db: str, collection: str):
1717
super().__init__()
1818
self._db=db
1919
self._collection=collection
20-
self._uri='mongodb://127.0.0.1:27017/'
20+
self._uri=uri
2121
self.client=MongoClient(self._uri)
2222
self.c_db=self.client[self._db]
2323
self.c_collection=self.c_db[self._collection]

‎ndn_python_repo/storage/storage_factory.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def create_storage(config):
3737
elifdb_type=='mongodb':
3838
db_name=config[db_type]['db']
3939
db_collection=config[db_type]['collection']
40-
ret=MongoDBStorage(db_name,db_collection)
40+
db_uri=config[db_type]['uri']
41+
ret=MongoDBStorage(db_name,db_collection,db_uri)
4142
else:
4243
raiseNameError()
4344

‎poetry.lock‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp