Simple pagination for pydantic models and SQLAlchemy Query objects
Project description
Introduction
This module will help you paginate results from any database if you use the sqlalchemy object Query. The PageModel pydantic model can be easily integrated with FastAPI and swagger.
Getting Started
Here is a brief example of how to use this code.
from pygination import paginate
from pygination.models import PageModel
query = db.query(models.City)
if country_id is not None:
query = query.filter(models.City.country_id == country_id)
page = paginate(query, offset, limit)
print(page)
# Previous page does not exist. Next page is 2. Total number of pages 4
page_model = PageModel.from_orm(page)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygination-0.0.11.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file pygination-0.0.11.tar.gz
.
File metadata
- Download URL: pygination-0.0.11.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f0a4546965b47454c0014aa3349ef8168429f2e6d5dfe0812724f72f387e07d |
|
MD5 | 153598697076ffcd17d6f7f945c96ef5 |
|
BLAKE2b-256 | 567dc3a145722921c4e29b641886ea390eddde94949f4135a18a680dda95249a |
File details
Details for the file pygination-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: pygination-0.0.11-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f0acf6e112a9ba800a726d7dacd27493e6f4bc09793f81f6178ae0fa3cb6a6 |
|
MD5 | 8fa192577097bd4fd7b9dacef32bdb2b |
|
BLAKE2b-256 | 0dd3b2873cfa009a58041461e2ac78e8acfbf1597ca7ea106489310271e14282 |