How to use paginate with sqlalchemy new query syntax
See original GitHub issueHi
I’m trying to migrate to Sqlalchemy 1.4.23 and activate the new query syntax. But can’t figure out how to use paginate function with it.
fastapi-pagination==0.8.3
from sqlalchemy.future import select
from models import UserModel
class User:
def _init__(self, db_session):
self.db_session = session
def get_users():
return select(UserModel)
The endpoint looks like this:
from fastapi_pagination.ext.sqlalchemy import paginate
from fastapi_pagination import Page, Params
@router.get('/get-users')
def get_users(self,
page_schema: PaginationParams = Depends(),
db_session: Session = Depends(get_request_db)) -> Page[UserSchema]:
users = User(db_session).get_users()
return paginate(users, page_schema)
I’m getting this error:
Also tried:
from sqlalchemy.future import select
from models import UserModel
class User:
def _init__(self, db_session):
self.db_session = session
def get_users():
return self.db_session.execute(select(UserModel))
but got this:
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How To Query Tables and Paginate Data in Flask-SQLAlchemy
You'll use the Flask shell to query a table, and get table records based on a column value (for example, an email). You'll...
Read more >pagination - SQLAlchemy and going through a large result set
Returns a Pagination object for the previous page. prev_num. Number of the previous page. query = None. the unlimited query object that was...
Read more >Paging Query Results - Flask-SQLAlchemy
Call SQLAlchemy.paginate() on a select statement to get a Pagination object. During a request, this will take page and per_page arguments from the...
Read more >wizeline/sqlalchemy-pagination: Small utility to ... - GitHub
Small utility to paginate SqlAlchemy queries. . Contribute to wizeline/sqlalchemy-pagination development by creating an account on GitHub.
Read more >Several pagination methods of SQLAlchemy and Flask ...
1.sets the index offset with offset (), limit () limits the amount taken. Db.session. · 2. Use Slice (offset, amount of removal )...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok, thank you for your effort on the project @uriyyo
Hi @rafa761,
Currently
fastapi-pagination
does not supportsqlalchemy
1.14
version. I am planing to include support at version0.9.0
.