Skip to main content

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


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.13.tar.gz (53.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygination-0.0.13-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pygination-0.0.13.tar.gz.

File metadata

  • Download URL: pygination-0.0.13.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pygination-0.0.13.tar.gz
Algorithm Hash digest
SHA256 e641beb27a22777b6568445ebae2de55243c18181cd4daef9a92457ceefebd5a
MD5 28fa3148eccd5111918e524dc9c88d69
BLAKE2b-256 bbfcdc45ec2c08ed7d31f64541fbcf8a4c7d0ad4952fe7ef42ff9223a2021f17

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygination-0.0.13.tar.gz:

Publisher: python-publish.yml on enerBit/pygination

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygination-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: pygination-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pygination-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 44ded0adfc9a15e181bdd17408dd36660e0f4b5eec8cfcae2575553bba8a0fe5
MD5 894d01960625396548add801b59f9023
BLAKE2b-256 183f4549a9b197a5c324454bd93d4e7466699181cf580478fd4e5c979a47e684

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygination-0.0.13-py3-none-any.whl:

Publisher: python-publish.yml on enerBit/pygination

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page