Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

How to store a users input into a database?

FrogDeKikker
FrogDeKikker

So, I want to store a users input, into a database, but I really don't know how to.
Could anyone please help me with it?

1 year ago

Voters

Comments

TopNew
2
VulcanWM
VulcanWM

What language?

1 year ago
1
FrogDeKikker
FrogDeKikker

Python

@VulcanWM

1 year ago
1
FrogDeKikker
FrogDeKikker

Since you made a login and signup page, on your profile page, I think you know alot about it

@VulcanWM

1 year ago
1
VulcanWM
VulcanWM

If you want to use replit db you can do the code below

from replit import db
db[‘key_name’] = ‘value’
note that replit db doesn’t work in the console and you should do it in web apps like flask


@BartKeijzer

1 year ago
1
FrogDeKikker
FrogDeKikker

and how to add a users input to that db?

@VulcanWM

1 year ago
1
VulcanWM
VulcanWM

like flask or just normal input?

@BartKeijzer

1 year ago
1
FrogDeKikker
FrogDeKikker

what is flask?
i mean just like test = input('anything')


@VulcanWM

1 year ago
1
VulcanWM
VulcanWM

Flask is a way to make websites where other people can use the repl with the database without any problems
When you do normal inputs (it is in your console) so the database will only work for you
But if you want to do normal input, use the code below

from replit import db
name = input(“What is your name?”)
data = input(“What do you want to save?”)
db[name] = data

@BartKeijzer

1 year ago
1
FrogDeKikker
FrogDeKikker

so will that work?
can the replit owner view the db also?

@VulcanWM

1 year ago
1
VulcanWM
VulcanWM

It will work for you
There is some website to view your data apparently
You can do some code to view it tho

@BartKeijzer

1 year ago
1
VulcanWM
VulcanWM

To view all your data do
for i in db.keys():
print(f”{str(i)}: {str(db[i])}”)

@BartKeijzer

1 year ago
1
FrogDeKikker
FrogDeKikker

and where to put what db i want to view?

@VulcanWM

1 year ago
1
VulcanWM
VulcanWM

What isn’t working?

@BartKeijzer

1 year ago
1
VulcanWM
VulcanWM

What error and which code?

@BartKeijzer

1 year ago
Load more