sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres
Hello! I'm having difficulties making the PostgreSQL to Postgres switch using Flask-SQLAlchemy. In my new project, I've already added the DATABASE_URL variable to connect to the database as it was previously. However, I'm encountering the following error:
raise exc.NoSuchModuleError(
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres
I don't know what to do. Here's my code:
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
Project ID: 0efe927a-43aa-4eba-b481-0724b8ec2063
Solution:Jump to solution
in the database service edit the
DATABASE_URL
variable as replace postgres://
with postgresql://
15 Replies
Project ID:
0efe927a-43aa-4eba-b481-0724b8ec2063
deployment logs please https://bookmarklets.up.railway.app/log-downloader/
That file, correct?
Solution
in the database service edit the
DATABASE_URL
variable as replace postgres://
with postgresql://
then redeploy your flask service
My god, yes, it seems that the error has stopped, you are a god.
If you could help me with this last thing now, instead of running the server to open on Railway, it seems to be trying to run on localhost, my code:
from sistemaLagoa import app
if name == "main":
app.run(debug=True)
Below is the log file:
send your main.py please
My main.py file contains exactly:
from sistemaLagoa import app
if name == "main":
app.run(debug=True)
But the _ _init __.py file where I configure the application:
thats not standard, so im not sure if this will work, add this as a railway.json file to your project
and make sure you have
gunicorn
in your requirements.txtAlright, in my project, there was already a file called Procfile that contained:
web: gunicorn main:app
Nevertheless, I added the railway.json as you suggested, but unfortunately, it crashed:
/bin/bash: line 1: gunicorn: command not found
(This line repeated 6 times).
you need
gunicorn
in your requirements.txt
you can also delete the ProcfileIt worked, thank you very much. I've saved your help in my favorites, and I'll return the favor as soon as I can. If I seemed rude in any way, I'm sorry, it was ChatGPT translating from Portuguese to English.
not rude in anyway! ChatGPT did a pretty good job at translating!