script for adding new user

master
Paul Walko 2018-04-08 17:35:53 +00:00
parent 322d4ebe3e
commit 5998a68683
1 changed files with 24 additions and 0 deletions

24
add_user.py Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
import pymongo
def checkpoint(message):
"""Prints [CHeckpoint] <message>
"""
print("[Checkpoint] {}".format(message))
def main():
"""Adds new user to mongodb
"""
id = 123456
weight = 150
gender = 'F'
# Connect to mongodb & add user
collection = pymongo.MongoClient().group23.bac_monitoring
collection.update({'id': 123456}, {'$set': {'weight': weight, 'gender': gender}}, upsert=True)
checkpoint("Added user \'{}\' with weight {} and gender {}"
.format(id, weight, gender))
main()