Files
2022-04-06 14:32:09 +02:00

36 lines
1.0 KiB
Python

import pymongo
import getpass
import uuid
# initialize connection to database
config = {
"username": "admin",
"password": "pass",
"server": "localhost:27017",
}
connector = "mongodb://{}:{}@{}".format(config["username"],config["password"], config["server"])
client = pymongo.MongoClient(connector)
db = client["groclist"]
username = input("Username: ")
password = getpass.getpass("Password: ")
uuid = str(uuid.uuid4())
email = input("Email-adres: ")
full_name = input("Volledige naam: ")
list_id = ""
user_cred = {"username": username, "password": password, "uuid": uuid}
user_info = {"uuid":uuid, "email": email, "name": full_name ,"listid": list_id}
stores_list = {"stores_name": ["Jumbo","AH","Boons","Aldi","Lidl"]}
item_list = {"stores_name" : 1}
if db.user_cred.find_one({"username": username}):
print("Username already exists\n")
exit()
else:
cred_record = db.user_cred.insert_one(user_cred)
info_record = db.user_info.insert_one(user_info)
print("User created")
stores_record = db.stores_list.insert_many(stores_list)