SQLAlchemy integration of jQuery DataTables
Project description
sqlalchemy-datatables is a library providing an SQLAlchemy integration of jQuery DataTables. It helps you manage server side requests in your application.
It is framework agnostic, tested with Pyramid and Flask mainly.
It only depends on SQLAlchemy, and is compatible with versions 1.9.x and 1.10.x of DataTables.
Installation
To install the stable version:
pip install sqlalchemy-datatables
Usage
views.py
@view_config(route_name='data', renderer='json')
def data(request):
"""Return server side data."""
# defining columns
columns = []
columns.append(ColumnDT('id'))
columns.append(ColumnDT('name', filter=upper))
columns.append(ColumnDT('address.description'))
columns.append(ColumnDT('created_at'))
# defining the initial query depending on your purpose
query = DBSession.query(User).join(Address).filter(Address.id > 14)
# instantiating a DataTable for the query and table needed
rowTable = DataTables(request.GET, User, query, columns)
# returns what is needed by DataTable
return rowTable.output_result()
You can find detailed working examples for Pyramid and Flask in the repository.
Documentation
The latest documentation is available online on Read the Docs.
Changelog
This project adheres to Semantic Versioning. Every release, is documented on the Github releases page.
License
The project is licensed under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for sqlalchemy-datatables-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ecaf29576c312ea37a0f34f26c3c3e69479e4da9789dff4795ec36664d6aa6 |
|
MD5 | e408d1130c10491438009e8a3f06e443 |
|
BLAKE2b-256 | b1b14a214f7032a129e243a5335b454541018f9bddd2959226d6bf95b89f67f8 |