23 lines
604 B
Python
23 lines
604 B
Python
import pymongo
|
|
import getpass
|
|
import uuid
|
|
|
|
myclient = pymongo.MongoClient("mongodb://admin:pass@localhost:27017/")
|
|
username = input("Username: ")
|
|
password = getpass.getpass("Password: ")
|
|
uuid = str(uuid.uuid4())
|
|
email = input("Email-adres: ")
|
|
full_name = input("Volledige naam: ")
|
|
|
|
mydb = myclient["groclist_db"]
|
|
mycol = mydb["groclist_users"]
|
|
|
|
mydict = {"username": username, "password": password, "groclist_uuid": uuid, "email": email, "name": full_name}
|
|
if mycol.find_one({"username": username}):
|
|
print("Username already exists\n")
|
|
exit()
|
|
else:
|
|
x = mycol.insert_one(mydict)
|
|
print("User created")
|
|
|