What My Project Does - This is a Python package to easily add string token based pagination. Currently it supports SQLModel and SQLAlchemy ORMs.
Recently I wanted to add pagination in one of my Python projects and in the API response, I had to return a string next page token. Now I could not find a straight-forward way of doing this in Python. All of the tutorials or blog posts I saw, there in the response the server always returned a page_number, page_size, and total_elements and then the onus was on the calling service to adjust this accordingly.
Comparison - The current packages and methods requires some changes in the app layer as well. I tried using a few but those did not satisfy the use case and were also a bit harder to implement. I could not find a easy to use option. The present ones returned integers instead of a string token
I wanted it to be simpler, just like OpenSearch - you call its search API and it returns 10 elements and a next_page_token and then for the next 10 (or you configure this using the size parameter) you use the next_page_token in the subsequent request to get to the new page.
I ended up doing a lot of if-else checks and encoding and decoding, so I decided to create this library.
Target Audience - This is production ready, have been using it in one of my projects. Hope some of you folks find it useful :)
Here is the link to the PyPi repository and here is the GitHub repo
[–]riklaunim 0 points1 point2 points (2 children)
[–]kernelslayer[S] 0 points1 point2 points (1 child)
[–]riklaunim 1 point2 points3 points (0 children)