postgresql
What changes do I need to make in the fastapi demo app to be able to access a postgresql? Both are from Railway templates and running in the production environment. I'm novice to all this.
18 Replies
Project ID:
3ffb43c3-27a4-47ba-b079-79313c5ebe25
3ffb43c3-27a4-47ba-b079-79313c5ebe25
add a postgre database plugin to your project
setup the variable references to the database in your service
ust use your postgre python package of your choosing and connect using the environment variables
How do I add a postgre database plugin to a project?
I have created variable references
Sample code how to fetch data from the postgre database?
once you are in the project you click the plus button in the top right
then once the database is added, setup the variable references in your service that will be using the database
https://docs.railway.app/develop/variables#reference-variables
as for sample code, you'll have to read some tutorials
Ah yes I have added the postgresql, do you have a tutorial how to initialize it from requirements.txt and main.py so it can be used in the code? I looked in your doc library but could not find any suitable sample.
that's more of a question you answer by reading or watching tutorials
ok, do you know how I can get professional services to help me out - do you offer a service like this?
these help threads are intended for questions about the platform.
I'm sure there's some great YouTube videos on how to query postgre from python that you could watch!
ok
if you have any questions involving railway or issues with railway, feel free to ask those here
I can't figure out why pip command does not work in my code - it works in my local development:
File "main.py", line 1
pip install mysqlclient
^
@Brody is the syntax different in railway for pip? if so how do I install mysqlclient in the main.py?
please watch this video
https://www.youtube.com/watch?v=oLlT6c6jA-M
#🛂|readme #5
in your original question you ask how to use postgre, but now you are trying to install a mysql package, i can recommend you stick with postgre
Ok I got it to work with postgre by including it in the requirements.txt
But I think there is some issue with MySQL - it did not even work on the Query UI interface when I run Select * from Customers - page crashes and shows "Application error: a client-side exception has occurred (see the browser console for more information)."
Also when I added mysqlclient==2.1.1 to the requirements.txt it also throws build errors.
1. postgre and mysql are two different things.
2. please don't rely on the data tab of the database plugins
1. yes I'm aware, I have worked with both of them previously
2. ok noted
Thanks for your help @Brody
no problem!