Ask coding questions

← Back to all posts
How do I make this work how I want it?
MisledWater79 (0)

I am trying to make a login thing in python and I'm using json to store the logins and passwords(I know not the best way to store it safely) and I cant get it to work, It changes the file but doesnt add the new user to it. Thanks in advance!

Answered by OldWizard209 (1498) [earned 5 cycles]
View Answer
Comments
hotnewtop
OldWizard209 (1498)

Nope, you shouldn't be using .json or.txt. It is the worst way to save data. You should use a database. As you are on replit, use their database. It is very simple and uses key-value pairs. To create a password and username into the database use this code:

from replit import db

db["username"] = "password"
print(db["username"])

If you want to get the username and pas from users:

from replit import db

user_name = input("Enter your Username: ")
password = input("Enter your password: ")

db[user_name] = password
print(db[user_name])

NEVER save data in a json file. One command in the shell and bai bai to all your data. Hope I helped.

MisledWater79 (0)

@OldWizard209 Where can I learn more on repels database?

Flyingcrabs (29)

Np you can get it in the side bar of your repl hit the coins thing and on top there is a blue database click it and you can get this doc @MisledWater79

Flyingcrabs (29)

Hehe love your password 5678 and username dav
repl keeps it private but still i know how to steal the key a value

MisledWater79 (0)

@Flyingcrabs tbh I thought i had it as dave but i guess not lol

Flyingcrabs (29)

Never ever use json file repl is good and it is also easy to learn