DKit — Data Toolkit
A Python data-processing library and CLI for data engineering and exploration. Data is handled in a canonical format (iterators or lists of dicts) and the library provides facilities to translate between that format and a wide variety of storage formats, manage schemas, manipulate data, and generate reports.
Version: 26.7.1 | Requires: Python ≥ 3.11 | License: MIT
Installation
pip install libdkit # from PyPI
pip install . # from source
pip install -e . # editable install for development
Library overview
| Package | Purpose |
|---|---|
dkit.etl |
Sources, sinks, transforms, schema management, ETL model |
dkit.etl.extensions |
Format extensions: Arrow, Avro, Parquet, SQLAlchemy, Pandas, Spark, REST, Protobuf, XLS/XLSX, Athena, HDF5 |
dkit.data |
Aggregation, EDA, filtering, histograms, window functions, schema inference, fake data |
dkit.doc2 |
Programmatic document builder — PDF (ReportLab), DOCX, HTML, Markdown renderers; email pipeline |
dkit.algorithms |
Trie, t-digest |
dkit.parsers |
URI parser, type parser, parser helpers |
dkit.plot |
Sparklines, console plots |
dkit.utilities |
Logging, CLI helpers, SMTP/email, Jinja2, security, ZMQ, concurrency, benchmarking |
dkit.shell |
Shell and config utilities |
Supported data formats
| Format | Read | Write |
|---|---|---|
| JSON / JSONL | yes | yes |
| CSV | yes | yes |
| Apache Parquet | yes | yes |
| Apache Avro | yes | yes |
| MessagePack | yes | yes |
| Excel (XLS/XLSX) | yes | yes |
| SQL (via SQLAlchemy) | yes | yes |
| HDF5 | yes | yes |
| XML | yes | — |
| Protocol Buffers | yes | yes |
Schema management
Schemas are stored in a compact shorthand encoding (e.g. String(str_len=20))
and validated using Pydantic. Export is supported for:
- Apache Arrow
- Apache Avro
- SQL DDL (via SQLAlchemy, any supported dialect)
- Apache Spark
- Pandas DataFrame dtypes
- Python dataclasses
- GraphViz entity-relation diagrams
ETL model
The ModelManager maintains connections, endpoints, entities, queries,
transforms, relations, and encrypted secrets in a YAML model file.
from dkit.etl.model import ModelManager, Entity
m = ModelManager.from_file("model.yml")
# infer a schema from data
with m.source("data/input.jsonl") as src:
entity = Entity.from_iterable(src)
m.entities["person"] = entity
# coerce CSV data to schema and write to parquet
with m.source("data/input.csv") as src:
with m.sink("output/result.parquet") as snk:
snk.process(entity(src))
Document generation
from dkit.doc2.document import Document
from dkit.doc2.html_renderer import HtmlRenderer
doc = Document()
doc.add_template("# Hello\n\nThis is a **report**.")
renderer = HtmlRenderer(css="email.css")
renderer.render(doc, "report.html")
# inline CSS for email clients
html = renderer.render_email_string(doc)
CLI — dk
The dk command-line tool exposes the library for interactive and scripted
data processing. Run dk MODULE -h for full options on any module.
dk MODULE [subcommand] [options]
Maintenance modules
| Module | Purpose |
|---|---|
dk schemas |
Manage entity schemas — infer, list, export, reflect from SQL/HDF5 |
dk connections |
Manage database connections |
dk endpoints |
Manage data endpoints |
dk queries |
Manage SQL queries |
dk transforms |
Manage field transform rules |
dk mapping |
Manage entity-relation mappings |
dk admin |
Configuration administration |
Action modules
| Module | Purpose |
|---|---|
dk run |
Run ETL pipelines, queries, and aggregations |
dk xplore |
Explore and summarise data interactively |
dk diff |
Find differences between two datasets |
dk build |
Build documents from Markdown sources |
Data exploration (dk xplore)
dk xplore head data.jsonl # first n rows
dk xplore summary data.jsonl # field statistics
dk xplore histogram data.jsonl -f price # histogram for a field
dk xplore count data.jsonl -f status # count by field value
dk xplore distinct data.jsonl -f country
dk xplore duplicates data.jsonl -k id
dk xplore view data.jsonl # interactive grid
dk xplore table data.jsonl # tabular output
dk xplore fields data.jsonl # list field names
dk xplore struc data.jsonl # structure map
dk xplore plot data.jsonl # plot grammar
dk xplore sample database.db # sample from DB tables
Schema operations (dk schemas)
dk schemas infer data.csv # infer schema from data
dk schemas ls # list stored schemas
dk schemas print person # print a schema
dk schemas export person --format arrow
dk schemas sql-reflect mydb --connection sqlite
dk schemas grep "person.*"
Running pipelines (dk run)
| Subcommand | Purpose |
|---|---|
etl |
Run an ETL process (format conversion with optional transforms) |
agg |
Group-by aggregation |
join |
Join two datasets |
pivot |
Create a pivot table |
melt |
Transpose a pivot table back to key:value pairs |
query |
Execute a SQL query |
exec |
Execute a driver-level query (DDL etc.) |
report |
Run a report definition |
template |
Apply datasets to a Jinja2 template |
dk run etl input.csv -o output.parquet
dk run agg input.jsonl -o output.jsonl
dk run join left.jsonl right.jsonl -o result.jsonl
dk run pivot input.jsonl -o pivot.jsonl
dk run melt pivot.jsonl -o output.jsonl
dk run query --connection mydb "select * from person"
dk run exec --connection mydb "create index ..."
dk run report report.yml
dk run template template.j2 data.jsonl
Development
make test # run test suite with coverage
make build # build sdist and wheel
make install # install into current environment
make clean # remove build artefacts
Tests live in test/. Run from the repo root:
pytest # all tests
pytest --cov # with coverage report
Integration tests that require external services (HDFS, SFTP, ZMQ) are
prefixed with _test_ and excluded from the default run.
Project links
- Source: https://github.com/cobusn/dkit
- Issues: https://github.com/cobusn/dkit/issues
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libdkit-26.7.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: libdkit-26.7.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f6d19bd72da384c8474a35fc524b5a9053cb3e2f5d44939d6a26a7580a7c9be
|
|
| MD5 |
11b7c63c5289fe55417f9b2d23da3ceb
|
|
| BLAKE2b-256 |
183d3de1931a264aa9b58b698cd8d05fefae1ea229f42276f03f9464a90b481a
|