Add push.py to post documents to mongo database
This commit is contained in:
parent
6ece423b43
commit
6acd6c3169
|
@ -1,4 +1,6 @@
|
|||
# MongoDB Database parameters
|
||||
|
||||
CONNECTION_STRING = "mongodb://user:pass@mongoserver:27017/database"
|
||||
DATABASE = "uparcel"
|
||||
COLLECTION = "job-status-log"
|
||||
|
||||
|
|
15
push.py
Normal file
15
push.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from pymongo import MongoClient
|
||||
from config import *
|
||||
import sys
|
||||
import json
|
||||
|
||||
def push(document):
|
||||
client = MongoClient(CONNECTION_STRING)
|
||||
database = client[DATABASE]
|
||||
collection = database[COLLECTION]
|
||||
collection.insert_one(document)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
push(json.loads(sys.argv[1]))
|
||||
|
Loading…
Reference in a new issue