Skip to content
Sign upLog in
← Back to Community

How to make a real-time repl?

Profile icon
LincolnMiddle

I was just wondering how to make a real-time repl. I mean that the repl is publicly saved, like live chat repls or real-time leaderboards.

Answered by RYANTADIPARTHI [earned 5 cycles]
View Answer
Voters
Profile icon
ClementAtReplit
Profile icon
LincolnMiddle
Comments
hotnewtop
Profile icon
RYANTADIPARTHI

You can use a db in a repl to save. database.

Profile icon
LincolnMiddle

@RYANTADIPARTHI
How do you use a database?

Profile icon
RYANTADIPARTHI

@DSAEvan
tutorial:

https://docs.repl.it/misc/database

Profile icon
LincolnMiddle

@RYANTADIPARTHI
what about html?

Profile icon
RYANTADIPARTHI

@DSAEvan
you can't do it in html. it's not a good language for it. it's just a static language.

Profile icon
LincolnMiddle

@RYANTADIPARTHI
I would also like an example of how to use the database for python. I don't really get the instructions in the link you gave me.

Profile icon
RYANTADIPARTHI

@DSAEvan
import it first, then to save something, use db.keys() like this.

from replit import db db['something'] = something # this is assigning vars db.keys() # to save
Profile icon
LincolnMiddle

@RYANTADIPARTHI
But it says 'something' is not defined Traceback (most recent call last): File "main.py", line 3, in <module> db['something'] = something # this is assigning vars NameError: name 'something' is not defined

Profile icon
RYANTADIPARTHI

@DSAEvan
well, that's because you don't have a variable called something. I'm just giving an example. make your vars. something has to be something.

Profile icon
LincolnMiddle

@RYANTADIPARTHI
how do you define it? PS how did you write the code in that way? Can you give me the tutorial link?
I did: something = 'yay'

Profile icon
RYANTADIPARTHI

@DSAEvan
this:

soemthing = "something" db['something'] = something

like that.

Profile icon
RYANTADIPARTHI

@DSAEvan
it's a db. it stores like that.

Profile icon
LincolnMiddle

@RYANTADIPARTHI
nvm I did it, but how do you print the 'something' using the database

Profile icon
RYANTADIPARTHI

@DSAEvan
well, i guess, you just print the variable.

print(something)

Profile icon
LincolnMiddle

@RYANTADIPARTHI
do you have any real-time python repls? I would like a link to one of them

Profile icon
RYANTADIPARTHI

@DSAEvan
well, i don't have any. but. you can't link anyways. i have a django db. and that db is different from the one I'm giving you.

Profile icon
LincolnMiddle

@RYANTADIPARTHI
Yeah I did that but how does that relate to the DB. PS I'm going to click when I'm stisied

Profile icon
RYANTADIPARTHI

@DSAEvan
django db is different from the db you are using. so you can't link anything. but you can use the db you learned for good stuff. hope that helps.

Profile icon
CoolCoderSJ

You would need to run a server (On Node.js, Python, etc.) Then use databases to update info.

Profile icon
LincolnMiddle

@CoolCoderSJ
An example repl? How do you use databases?