Ask coding questions

← Back to all posts
Can you access replit's python project's database from a JS file?
BenasAlonderis

I have a Python project and I update the replit database with some Python scripts and I was wondering if it's possible to access the database with JS and if so how? I was having problems trying this, nothing worked I tried, maybe it's not possible?
THANKS

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
BenasAlonderis
Comments
hotnewtop
Coder100

They use the same db, if what you mean is replit db. Take this example:

run the python file

runs the nodejs file

If you mean web js, it's not possible because it would mean your db URL secret has to become public, and that's not secure. You would probably want to make it so your python flask or whatever gives it to your frontend in a template (like jinja2).

VulcanWM

You can do it in node.js but not in a js or html repl

BenasAlonderis

@VulcanWM So I can't access it with .js code if my project is a Python project?

VulcanWM

Even in an HTML JS CSS project you can’t access databases because normal js is for frontend and database are backend stuff @BenasAlonderis