New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sqlalchemy-awesome-pagination

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlalchemy-awesome-pagination

Python package for implementing sqlalchemy pagination

  • 1.0.3
  • PyPI
  • Socket score

Maintainers
1

SQLAlchemy Awesome Pagination

Github

SQLAlchemy Awesome Pagination is a small utility library that paginates an SQLAlchemy

object and returns the results ready for api serving.

If you are creating a service/micro-service oriented architecture, and cannot use fastapi/flask or other frameworks built in paginations or libraries, this is for you.

The sole purpose of this project was creating a minimal yet effective library to be used independently of frameworks.

Installation

The project requires sqlalchemy >= 1.1 installed.

Install with pip

pip install sqlalchemy_awesome_pagination

Features

  • Pagination

  • Sorting by sqlalchemy column

  • Sorting by direction

Usage/Examples

paginate() accepts 5 params:

query - SqlAlchemy object to be paginated

page_number - Page to be returned (starts and defaults to 1).

page_size - Maximum number of results to be returned in the page (defaults

to the total results).

direction - asc/desc - defaults to asc

sort_by - table column for sorting - defaults to sqlalchemy default sorting column(mostly id)


from sqlalchemy_awesome_pagination import paginate

from app import models

  

query =  self.db.query(

models.User.username,

models.User.email

)

  

results =  paginate(query, 2, 10, "asc", "email")

results2 =  paginate(query)

results3 =  paginate(query, 1, 15, "desc")

results4 =  paginate(query, 2, 20, None, "email")

Authors

Credits

This library is an adjusted version of the pagination module from

Big thanks to the authors and contributors for the idea!

Contributing

Contributions are always welcome! :)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc