Which import should I use for raw sql ? #1217
Unanswered
HuzaifahLutaaya
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi @HuzaifahLutaaya, You can use from fastapi_pagination.ext.sqlalchemy import paginate
GET_FILTERED_FOOD_QUERY = """
SELECT DISTINCT food_name
FROM clients
WHERE tenant_id = :tenant_id
AND (
:search::text IS NULL
OR internal_name ILIKE '%' || :search || '%'
)
ORDER BY internal_name
"""
@app.get("/items")
def read_items(db: Session = Depends(get_db)) -> Page[Any]:
return paginate(db, text(GET_FILTERED_FOOD_QUERY).bindparams(tenant_id=1, search=None)) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which of these, should I use for Raw SQL ?
https://github.com/uriyyo/fastapi-pagination/tree/main/fastapi_pagination
Suppose I have this query ;
Beta Was this translation helpful? Give feedback.
All reactions