How To Use Repl's Database
Repl.it has its own way of saving information called Repl Database. It is very easy to use and is great for making Log In Systems. In this tutorial, you will learn how to use repl's database by making a login system.
Before you can start using its functionality you will need to import it. You can do that by putting in
from replit import db
this will then install the database into your code.
The next thing you would want to do is create an area yourself where the user will be able to type in what they want their username or nickname to be. Have an input variable for what they decide to use. Next, you will need to add that input variable to the DB.
username = input()
Now, let's add a value that we want to save to this user.
value = input()
db["username"] = "value"
You can make the value anything you want. It could be money, coins, XP, etc. As you can see that when we set the keys they are the same as the input names.
Now that we have a way of creating an account now let's be able to log in.
LogUser = input()
GetValue = db["LogUser"]
Now we have a way of getting the user's value. You can implement this however you would like.
Pretty good! I like the idea and I'm trying to use a log in system in a game I'm creating. Could you tell me how to implement username and password system?
@MikeJMS8910 epic, I made this earlier tbh idk if I did that or not but none the less it works, although would you happen to know any db error handler code such as on key not found or smth (whatever it is obvi that code wont work).. it's good for checking if user exists like the example I put rather than just trying for an exception since an exception could be raised due to another error in the code.