jquery数据表的sqlalchemy集成
sqlalchemy-datatables的Python项目详细描述
sqlalchemy datatables是一个与框架无关的库,它提供jqueryDataTables>;=1.10的SQLAlchemy集成,并帮助您管理应用程序中的服务器端请求。
安装
通过pip安装:
python 3
$ pip3 install sqlalchemy-datatables
从源安装:
$ git clone git@github.com:Pegase745/sqlalchemy-datatables.git
$ cd sqlalchemy-datatables
$ pip3 install .
供款:
In a virtualenv
$ git clone git@github.com:Pegase745/sqlalchemy-datatables.git
$ cd sqlalchemy-datatables
$ make all
用法
@view_config(route_name='data',renderer='json')defdata(request):"""Return server side data."""# defining columns# - explicitly cast date to string, so string searching the date# will search a date formatted equal to how it is presented# in the tablecolumns=[ColumnDT(User.id),ColumnDT(User.name),ColumnDT(Address.description),ColumnDT(func.strftime('%d-%m-%Y',User.birthday)),ColumnDT(User.age)]# defining the initial query depending on your purpose# - don't include any columns# - if you need a join, also include a 'select_from'query=DBSession.query().\ select_from(User).\ join(Address).\ filter(Address.id>4)# instantiating a DataTable for the query and table neededrowTable=DataTables(request.GET,query,columns)# returns what is needed by DataTablereturnrowTable.output_result()
许可证
这个项目是根据麻省理工学院的许可证授权的。