skip to navigation
skip to content

Not Logged In

datatables 0.4.1

Integrates SQLAlchemy with DataTables (framework agnostic)

Latest Version: 0.4.9


The package is available on PyPI and is tested on Python 2.7 to 3.4

pip install datatables


Using Datatables is simple. Construct a DataTable instance by passing it your request parameters (or another dict-like object), your model class, a base query and a set of columns. The columns list can contain simple strings which are column names, or tuples containing (datatable_name, model_name), (datatable_name, model_name, filter_function) or (datatable_name, filter_function).

Additional data such as hyperlinks can be added via DataTable.add_data, which accepts a callable that is called for each instance. Check out the usage example below for more info.


class User(Base):
    __tablename__ = 'users'

    id          = Column(Integer, primary_key=True)
    full_name   = Column(Text)
    created_at  = Column(DateTime, default=datetime.datetime.utcnow)

    # Use lazy=joined to prevent O(N) queries
    address     = relationship("Address", uselist=False, backref="user", lazy="joined")

class Address(Base):
    __tablename__ = 'addresses'

    id          = Column(Integer, primary_key=True)
    description = Column(Text, unique=True)
    user_id     = Column(Integer, ForeignKey(''))

@view_config(route_name="data", request_method="GET", renderer="json")
def users_data(request):
    # User.query = session.query(User)
    table = DataTable(request.GET, User, User.query, [
        ("name", "full_name", lambda i: "User: {}".format(i.full_name)),
        ("address", "address.description"),
    table.add_data(link=lambda o: request.route_url("view_user",

    return table.json()


<table class="table" id="clients_list">
            <th>User name</th>

        serverSide: true,
        processing: true,
        ajax: "{{ request.route_url("data") }}",
        columns: [
                data: "id",
                "render": function(data, type, row){
                    return $("<div>").append($("<a/>").attr("href",;
            { data: "name" },
            { data: "address" }
File Type Py Version Uploaded on Size (md5) Source 2014-08-12 8KB
  • Downloads (All Versions):
  • 21 downloads in the last day
  • 237 downloads in the last week
  • 931 downloads in the last month