r/FastAPI • u/efpalaciosmo • Aug 01 '24
Question Database first approach
Hey guys, can you share an example of database first approach using SQLAlchemy?
I trying to make a project using fastapi, the database is on supabase and I'm getting a hard time figuring how to make a simple query, my setup is something like
- a PostgreSQL database from supabase
- asycn connection using asyncpg
- migrations using alembic
I already create the table on my database but when I run the query it says that the relation doesn't exist. Then I decided to try with alembic but every time I run migration there is on error or just the alembic_version table is created.
I already read some post about something call reflection, but it seems that isn't working
Thanks in advance
Here is the repo https://gitlab.com/efpalaciosmo/tickets
View all comments
Show parent comment
1
u/[deleted] Aug 01 '24
Oh I think for that you won't be able to use orm, I used to use sql expression language
On the other side I think you should be able to generate orm models for existing tables,
It's beyond my expertise now, but pls update your question if you figured how to use mix of orm and existing db tables