Skip to main content

A fastapi lowlevel pagination system

Project description

Fast Pagination

Description

A lowlevel, fast and easy to use package for creating and managing your own pagination system while FastAPI.

Keeping the pagination system simple was the main goal of this package.
You provide your own database querying logic and the pagination system will handle the rest.

Example

Imports

import fast_pagination as pg

Routes

@router.get(..., response_model=pg.generate_response_schema(SomeModel))
async def some_route(
    pagination: pg.Pagination[SomeModel] = Depends(
        pg.get_pagination_dependency(offset_kwargs={...},
                                     limit_kwargs={...},
                                     filter_kwargs={...})
    ),
    ...  # additional route dependencies goes here
):
    return await pagination.paginate(
        func=db_query_func,
        ...  # func kwargs goes here
    )

Services

async def db_query_func(page_request: PageRequest, **extra_kwargs) -> dict:
    ...  # db query logic goes here

    return {
        'results': results,
        'total_items': total_items
    }

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

fastapi-lowlevel-pagination-0.0.1.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

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