Skip to main content

sqlalchemy2-datatables

versions license badge

Summary

sqlalchemy2-datatables is a framework agnostic library providing an SQLAlchemy integration of jQuery DataTables >= 1.10, and helping you manage server side requests in your application.

Inspiration

This project was inspired by sqlalchemy-datatables developed by Michel Nemnom aka Pegase745.

Motivation

Given the sunstantial changes with SQLAlchemy 2.0 most of not all of the SQLAlchemy based datatables serverside solution will be outdated soon (labeit currently still supported in SQLAlchemy 1.4). Specifically deprecation of sqlalchemy.orm.Query will render those packages obsolete. SQLAlchemy2.0.

Installation

pip install sqlalchemy2-datatables

Examples

Generic CRUD style function:

from typing import Any
from sqlalchemy import Engine
from sqlalchemy import FromClause

from datatables import DataTable
from datatables.base import DTDataCallbacks

def get_datatable_result(
    params: dict[str, Any],
    table: FromClause,
    column_names: list[str],
    engine: Engine,
    callbacks: DTDataCallbacks | None,
) -> dict[str, Any]:
    """
    Get database results specifically formatted for a display via jQuery datatables.
    :param params: dict - request parameters
    :param table: FromClause - the sqlalchemy from clause
    :param column_names - List of column names reflecting the table columns in the desired order
    :param engine: Engine -  the sqlalchemy engine
    :param callbacks - datatables callbacks to populate jQuery datatables DT_* attributes
    :return dict with DataTable output for the jQuery datatables in the frontend view
    """
    datatable: DataTable = DataTable(
        request_params=params,
        table=table,
        column_names=column_names,
        engine=engine,
        callbacks=callbacks
    )
    return datatable.output_result()

The output dictionary that can be serialized and returned to jQuery datatables.

{
    "start": 0,
    "length": 5,
    "draw": 1,
    "recordsTotal": 1000,
    "recordsFiltered": 1000,
    "data": [
        {
            "id": 1,
            "col1": "value",
            "col2": "value",
            "col3": "value",
            "col4": "value",
        },
        {
            "id": 2,
            "col1": "value",
            "col2": "value",
            "col3": "value",
            "col4": "value",
        },
        {
            "id": 3,
            "col1": "value",
            "col2": "value",
            "col3": "value",
            "col4": "value",
        },
        {
            "id": 4,
            "col1": "value",
            "col2": "value",
            "col3": "value",
            "col4": "value",
        },
        {
            "id": 5,
            "col1": "value",
            "col2": "value",
            "col3": "value",
            "col4": "value",
        },
    ],
}

Metadata

Release files for sqlalchemy2-datatables 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy2-datatables 0.7.0
File Size Uploaded Provenance Actions
sqlalchemy2_datatables-0.7.0.tar.gz 15.6 kB Without provenance Details for sqlalchemy2_datatables-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy2-datatables 0.7.0
File Interpreter ABI Platform Actions
sqlalchemy2_datatables-0.7.0-py3-none-any.whl Python 3 none any Details for sqlalchemy2_datatables-0.7.0-py3-none-any.whl

Total release size: 24.7 kB

Release files / sqlalchemy2_datatables-0.7.0.tar.gz

Download URL sqlalchemy2_datatables-0.7.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
065352caa5405c3f592a43e38ec2c3a4f2a5725c9ac91b328dd3929cc17a0fc8
BLAKE2b-256 checksum
How to use checksums
79fb48e4e6a7c1d3c07acce7d671e2d78db790caed69ab02fb64d5cb3ef4ef9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sqlalchemy2_datatables-0.7.0-py3-none-any.whl

Download URL sqlalchemy2_datatables-0.7.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b552c7f02a0a120e6a16a208a4c0627e3bf892d45f26241a6873e3775c5ddc7
BLAKE2b-256 checksum
How to use checksums
e9e52d28bcfae6b848b218dc4e5e8f77295cdbf51c199274e604974cc8b6a509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sqlalchemy2-datatables 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page