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.
To install the stable version:
pip install sqlalchemy-datatables
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.
The latest documentation is available online on Read the Docs.
All notable changes to this project will be documented in this section.
This project adheres to Semantic Versioning and Keep A Changelog.
The project is licensed under the MIT license.