Connect to PostgreSQL db from Fastapi

Guys, is there a option to connect allready working PostgreSQL db on render with deploying Fastapi app also on render?
I cant figure it out.
Succesfully connected with db with dBeaver on my PC so db works well

The creator of fastapi has a demo project with Postgres. It’s pretty straightfoward to pull out the database specific components.

great… but it’s still not answer on my question…

Hi,

The link from the other community member probably does contain the information you need, but you would need to apply it to your project. Please be courteous to those that take the time to try and help.

You’ve provided no details about your setup, but FastAPI seems to use SQLAlchemy. So if you’re trying to connect it to your Render Postgres DB, put the “Internal Database URL” from the database dashboard into an Environment variable on your service (DATABASE_URL is common). Then reference that environment variable in the SQLAlchemy config, FastAPI & SQLAlchemy docs.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.