Skip to main content

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.

Build Status PyPi Version PyPi Downloads Code Quality Coveralls

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy-datatables-0.2.1.tar.gz (9.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page