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

Repl.it Database / External use

IlexisTheMadcat
IlexisTheMadcat

Hello, I want to migrate my discord bots to running on my personal local server, however I still want to use an online database.
I've had good luck with using the replit database, and I know how to get the URL of it, but how can I interact with my database on my computer within an async python script?
I do not want to use pickle or a local JSON (I can use a local JSON if there are no other options). My only intention with the database is to overwrite it with the local one, as to save it to the cloud.

2 years ago

Voters

Comments

TopNew
3
LordOfAllPie
LordOfAllPie

Start with this in a Repl (replit):

from os import getenv print(getenv("REPLIT_DB_URL"))

Now that we have your db url, use this in your computer's IDE:

from os import environ environ["REPLIT_DB_URL"] = "<INSERT YOUR DB URL FROM ABOVE HERE>" from replit import db

You can now use it on your local machine with that file.

9 months ago
3
Coder100
Coder100
print(os.getenv("REPLIT_DATABASE_URL"))

use this and copy the url that is printed.
Afterwards, u just need to add this to the database:

from replit import db db.db_url = "<...>"

**notes: ** Replit database was made specifically for replit, this is not an ideal solution, and there is no perfect solution.
For security, the database url is reset every once in a while, so you will have to update the url each time the url doesn't work anymore.

2 years ago
1
IlexisTheMadcat
IlexisTheMadcat

@Coder100
will this work at least to perform the dictionary updates when I do anything to db?

2 years ago
1
IlexisTheMadcat
IlexisTheMadcat

@Coder100
ok i will export to my local machine and try this

2 years ago
1
IlexisTheMadcat
IlexisTheMadcat

@Coder100

image

I do not think it will work...

2 years ago
1
Coder100
Coder100

hm
i guess the lib just doesn't want to work outside of replit environments, that's kind of expected unfortunately.

@SUPERMECHM500

2 years ago
1
19wintersp
19wintersp

@Coder100
@SUPERMECHM500
I built a GUI editor for ReplDB; if you have Java 14 or above, you can download and run it.

2 years ago
Load more