add_user.py created. Adds user/pass to the database for using app.

This commit is contained in:
2022-03-12 15:09:19 +01:00
parent 2f5fdeb690
commit ab379673b2
2 changed files with 53 additions and 13 deletions
+19
View File
@@ -0,0 +1,19 @@
import pymongo
import getpass
myclient = pymongo.MongoClient("mongodb://admin:pass@localhost:27017/")
username = input("Username: ")
password = getpass.getpass("Password: ")
mydb = myclient["groclist_db"]
mycol = mydb["groclist_users"]
mydict = {"username": username, "password": password}
if mycol.find_one({"username": username}):
print("Username already exists\n")
exit()
else:
x = mycol.insert_one(mydict)
print("User created")