Skip to content

aagusti/sqlalchemy-datatables

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 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.

About

SQLAlchemy integration of jQuery DataTables (Pyramid example)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.9%
  • Shell 2.1%