Skip to main content
PyPI Version

SQLAlchemy-Paginator

This module helps you to manage large data with pagination.

How this module work?

This module sqlalchemy_paginator.Paginator take an SQLAlchemy query - e.g.: Session.query(MyModel) and on calling page for specific page number it will fetch only required records from database instead of fetching all the records.

This class will also optimized the query for fetching total number of records from database against given query_set. Optimization will be applied only on the query that will be used for fetching total number of records. You can also provide the separate query in optional_count_query_set argument for fetching total number of records.

Usage

You can use this paginator module in python scripting code and in web based application code as well.

Example1

> from sqlalchemy_paginator import Paginator
> query = session.query(MyModel)
> paginator = Paginator(query, 5)
> for page in paginator:
>     print "page number of current page in iterator", page.number
>     print "this is a list that contains the records of current page", page.object_list

Example2

> from sqlalchemy_paginator import Paginator
> query = session.query(MyModel)
> paginator = Paginator(query, 5)
> page = paginator.page(page_number)
> print "to get total number of records against given query", page.paginator.count
> print "to get total number of pages", page.paginator.total_pages
> print "to get range of pages in list", page.paginator.pages_range
> print "to get index of the first object on this page", page.start_index
> print "to get index of the last object on this page", page.end_index
> if page.has_previous():
>     print "to get previous page number", page.previous_page_number
> if page.has_next():
>     print "to get next page number", page.next_page_number

How to install?

When pip is available, the distribution can be downloaded from PyPI and installed in single step

> pip install SQLAlchemy-Paginator

or you can use easy_install

> easy_install SQLAlchemy-Paginator

You can find more document in sqlalchemy_paginator/paginator.py module and a complete example in the tests/sqlalchemy_paginator_tests.py file of this Python module.

Release files for SQLAlchemy-Paginator 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SQLAlchemy-Paginator 0.2
File Size Uploaded
SQLAlchemy-Paginator-0.2.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for SQLAlchemy-Paginator 0.2
File Interpreter ABI Platform
SQLAlchemy_Paginator-0.2-py2-none-any.whl Python 2 none any Details

Total release size:11.1 kB

Release files / SQLAlchemy-Paginator-0.2.tar.gz

Download URL SQLAlchemy-Paginator-0.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fabb8fd28904a161252f2afa733e2a10ca0ded4556b36f93f481f605c5fa8948
BLAKE2b-256 checksum
How to use checksums
d79218aeeba448c13900caaabd229324d0e8ca0556177c669dc235c97e042cbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/2.7.10

Release files / SQLAlchemy_Paginator-0.2-py2-none-any.whl

Download URL SQLAlchemy_Paginator-0.2-py2-none-any.whl
Size 6.4 kB
Tags Python 2
SHA-256 checksum
How to use checksums
9c3690d24a20867ab4151ca3d52e60dc3f085fbe13729e09687aaa1ac66d85c8
BLAKE2b-256 checksum
How to use checksums
45782ee5916d671d6e8c6ac5cbe84feba953e2c72a81bb699440974334c25fa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/2.7.10

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page