Skip to content

SQLAlchemy integration of jQuery DataTables (Pyramid example)

License

Notifications You must be signed in to change notification settings

ddimmich/sqlalchemy-datatables

 
 

Repository files navigation

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

All notable changes to this project will be documented in this section.

This project adheres to Semantic Versioning and Keep A Changelog.

License

The project is licensed under the MIT license.

About

SQLAlchemy integration of jQuery DataTables (Pyramid example)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.4%
  • Shell 1.6%