queries.pyi / aiosql
stealthrabbi opened this issue · 1 comments
stealthrabbi commented
I'm attempting to create a new table entity, and writing a repository to query the database.
- I was trying to figure out how to update
env.py
to support auto-generation with alembic, but wasn't sure where the "base metadata" lives, or how to specify it exactly. Do I need a file that imports all the models inapp/models/domain
? queries.py
referencesqueries.pyi
. The readme doesn't specify how to use aiosql, so I'm not sure what to do with it exactly. Is it required for doing queries?
nsidnev commented
- This project doesn't use sqlalchemy for anything other than migrations, so you simply can't automatically generate migrations with alembic. If you want this to be possible, then you'll have to change the way this project works with the database or use wrappers around pydantic and sqlalchemy or something similar.
queries.py
is a simple module that defines a holder for rawSQL
queries fromapp/db/queries/sql
. The files from this folder are parsed by aiosql and as a result create dynamic functions for the corresponding queries from the files. Unfortunately,aiosql
cannot generate typing for these modules (simply because it all works at runtime), so there is a corresponding toquery.py
module calledquery.pyi
that simply defines the typings for functions generated through aiosql. If you want to know more about aiosql, check its documentation for a better explanation of this.
FIY. A little more information on your questions can be found in this issue.