Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chapagainmanoj/databases-extensions
A query building extensions for sqlalchemy with encode/databases to apply pagination, filter, search and sorting to query
https://github.com/chapagainmanoj/databases-extensions
cursor-pagination databases query-builder sqlalchemy-core
Last synced: 15 days ago
JSON representation
A query building extensions for sqlalchemy with encode/databases to apply pagination, filter, search and sorting to query
- Host: GitHub
- URL: https://github.com/chapagainmanoj/databases-extensions
- Owner: chapagainmanoj
- License: other
- Created: 2021-03-20T15:13:00.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-21T13:59:06.000Z (over 3 years ago)
- Last Synced: 2024-12-06T08:16:13.152Z (28 days ago)
- Topics: cursor-pagination, databases, query-builder, sqlalchemy-core
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# databases-query-extensions
An query building extensions for sqlalchey with encode/databases to apply pagination, filter, search and sorting to query## Installation
```pip install databases-extensions```
## Example
Construct page params
```python
page_params = PaginationParams.construct(
first=3, filter={"completed.is_true": ""}
)
```
apply cursor pagination and get results
```python
from extensions import CursorPagination
...
query = example.select()
pagination = CursorPagination(database, query)
paginated = await pagination.page(page_params)
```apply filters, search, sorting or pagination and get query
```
from extensions import query_builder
...
query = example.select()
cursor_column="created_date"
query = query_builder(query, page_params, cursor_column)
```A complete query params example
```python
{
"first": 100,
"after": ,
"afterWith": ,
"search": {
"columns": ["col1", "col2"],
"value": "new"
},
"filter": {
"status.eq": "Pending"
},
"sort": "createdAt",
"order": "asc"
}
```