Add Postgres To Flask
I have some truble connecting Postgresql to Flask and deploying it to Railway App
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1195758806710366289/Screenshot_2024-01-13_at_5.58.24_PM.png)
42 Replies
Project ID:
c6894929-c040-4842-8c83-4516d57a14fe
c6894929-c040-4842-8c83-4516d57a14fe
can anyone help me?
have you added the database variable references to your backend? https://docs.railway.app/guides/variables#referencing-another-services-variable
I am new to deploying, its my first app that I will deploy it, it is built with Flask+db+React
okay that's cool, but that doesn't quite answer the question
I added this one only to the backend:
could you also provide what to add in .env for flask?
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1195787326748639373/Screenshot_2024-01-13_at_7.49.17_PM.png)
you don't need an .env file
configuration? for example config.py
this looks good to me, are you using that environment variable in your code
yes: FLASK_APP=main
FLASK_ENV=development
FLASK_DEBUG=True
I'm sorry but that doesn't answer the question
no
Just added it to Railway
you need to use the DATABASE_URL environment variable in code when connecting to the database
How?