Metadata-Version: 2.1
Name: pygination
Version: 0.0.4
Summary: Simple pagination for pydantic models and SQLAlchemy Query objects
Home-page: https://github.com/jdmoralesar/pygination
Author: Enerbit
Author-email: jdmoralesar@gmail.com
License: UNKNOWN
Download-URL: https://github.com/jdmoralesar/pygination/archive/refs/tags/0.0.1.tar.gz
Keywords: python pagination
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.7, <3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt


# 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)
```

