Metadata-Version: 2.4
Name: pygination
Version: 0.0.13
Summary: Simple pagination for pydantic models and SQLAlchemy Query objects
Author-email: pablete <jtamayoh@gmail.com>, mike-diomedes <michael.guzman.personal@gmail.com>, jdata <jdmoralesar@gmail.com>
Maintainer-email: pablete <jtamayo@enerbit.co>
License-File: LICENSE.txt
Requires-Python: >=3.7
Requires-Dist: pydantic
Requires-Dist: sqlalchemy
Description-Content-Type: text/markdown

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