Skip to main content

linaldb (Python native bindings)

Embedded native Python bindings for LINALDB — a PyO3 extension linking the same synchronous engine the CLI/REPL runs (TensorDb/execute_line, src/engine/db.rs + src/dsl/mod.rs) directly into your Python process. No server, no network — this is the "use it like SQLite" story, as opposed to clients/python (a thin HTTP client for a running linal serve). See ../EMBEDDED_CONTRACT.md for the exact result shapes this module implements.

Published on PyPI as linaldb:

pip install linaldb

Status

14 releases on PyPI so far, 0.1.0 through 0.1.14 — most bumped purely to pick up a real engine fix (this crate has no code of its own beyond the PyO3 bindings), each found via genuine end-to-end testing against real data in the linal-hub sibling project rather than isolated unit tests. Two of the more severe: 0.1.4 (2026-09-13) fixed EXPLAIN LINEAGE misattributing ancestry across a zero-copy TRANSPOSE (a transposed matrix and its untransposed source could hash identically); 0.1.5 (2026-09-13) fixed a JOIN's SELECT/WHERE/aggregate expressions silently returning the wrong table's value for a qualified column when both sides shared a bare column name — no error, just wrong data. See CHANGELOG.md for the complete version-by-version history.

Usage

import linaldb

db = linaldb.Db()  # persists to ./data by default, exactly like the CLI
db.execute("CREATE DATASET t COLUMNS (id: Int, score: Float)")
db.execute("INSERT INTO t VALUES (1, 0.9), (2, 0.4)")

result = db.execute("SELECT * FROM t WHERE score > 0.5")
print(result.columns, result.rows)   # ExecuteResult
df = result.to_pandas()              # requires the `pandas` extra

db.execute("SAVE DATASET t")
dataset = db.dataset("t")
df = dataset.to_pandas()             # reads data.parquet directly off disk

Load data straight from memory — no file, no DSL parsing, bit-exact:

import numpy as np

vectors = np.random.default_rng(0).standard_normal((1000, 64)).astype(np.float32)
db.load_numpy("library", vectors, column="e", columns={"id": np.arange(1000)})
db.load_arrow("other", pyarrow_table)   # or any pyarrow Table / RecordBatch

float64 vectors, NaN/infinite values and unsupported Arrow types raise LinalError instead of being converted.

Fingerprints and spectra:

db.load_numpy("cands", np.zeros((n, 1), np.float32), column="unused",
              bit_columns={"fp": fingerprint_bits})          # (n, 2048) bool -> BitVector(2048)
db.load_arrow("library", pa.table({"id": ids, "pm": precursor_mz,
                                   "spec": linaldb.peaks_array(spectra)}))  # [(mz, int), ...]
db.query('SELECT id, SPEC_COSINE(spec, spec, 0.01) AS s FROM library')

Large libraries:

db.load_numpy("lib", vectors, column="e", quantize="F16")      # Vector(d, F16): half the memory
arr, meta = linaldb.sparse_array([(idx, vals), ...], 100_000)    # SparseVector(100000)
db.load_arrow("binned", pa.Table.from_arrays([arr], schema=pa.schema([pa.field("s", arr.type, metadata=meta)])))
``` See [`../EMBEDDED_CONTRACT.md`](../EMBEDDED_CONTRACT.md) §1b.

See
[`examples/digit_classification_embedded.py`](examples/digit_classification_embedded.py)
and the Jupyter notebook
[`examples/digit_classification_embedded.ipynb`](examples/digit_classification_embedded.ipynb)
for a complete real-data walkthrough — the same real UCI
handwritten-digits classification workflow
[`clients/python/examples/digit_classification.py`](../python/examples/digit_classification.py)
runs over HTTP, ported to embedded mode: no `linal serve` subprocess at
all, just an in-process `Db()`, an in-process classification query, and
an independent numpy recomputation from the dataset export, cross-checked
against the SQL result.

## Build

This crate vendors HDF5 and pulls in arrow/tokio/axum/zarrs as
dependencies of the root `linal` crate (`Cargo.toml` here has a `path`
dependency on `../..`) — the first build compiles all of that, same as
building the CLI itself; a `.cargo/config.toml` here points the build at
the repo-root `target/` dir to avoid a second full vendor build if you've
already built the root crate.

Requires a Rust toolchain (`cmake` + a C toolchain for HDF5, per the root
`CLAUDE.md`) and [`maturin`](https://www.maturin.rs/):

```bash
python3 -m venv .venv && source .venv/bin/activate
pip install maturin
maturin develop           # builds the extension, installs it into .venv

If your Python interpreter is newer than PyO3's currently-supported maximum CPython version, set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 for the build (PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 maturin develop) — this repo was built and verified against CPython 3.14 that way.

About

LINALDB is built by Gorigami, a software company based in Colombia, and maintained by Nicolás Balaguera. See the project README and LICENSE for the full picture and licensing terms.

Development

source .venv/bin/activate
pip install -e ".[dev]"
maturin develop
pytest tests/

No live server needed for anything here (that's the whole point of embedded mode) — tests and examples all run against an in-process Db().

Metadata

Release files for linaldb 0.1.19

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

Built distributions (wheels)

Table of built distributions (wheels) for linaldb 0.1.19
File Interpreter ABI Platform Actions
linaldb-0.1.19-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for linaldb-0.1.19-cp39-abi3-win_amd64.whl
linaldb-0.1.19-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for linaldb-0.1.19-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
linaldb-0.1.19-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for linaldb-0.1.19-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 31.4 MB

Release files / linaldb-0.1.19-cp39-abi3-win_amd64.whl

Download URL linaldb-0.1.19-cp39-abi3-win_amd64.whl
Size 11.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
068be8fbffda46e4979ee8528fc01518b7650bdee13b8d01d0226ef00483979d
BLAKE2b-256 checksum
How to use checksums
0d0217b0560ef5f22118dc6b0c7259bf8956cdeb4ec6ebdeb05cbf045909fdd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / linaldb-0.1.19-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL linaldb-0.1.19-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 11.1 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d94ffaa4908c73398c0c65cced3b096e945e681bcd3ca7c7ef7505f0e110d886
BLAKE2b-256 checksum
How to use checksums
004e5575c815f20523babffa499e14a5b12f74f26da3756bb23db1825dda6d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / linaldb-0.1.19-cp39-abi3-macosx_11_0_arm64.whl

Download URL linaldb-0.1.19-cp39-abi3-macosx_11_0_arm64.whl
Size 9.0 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fddc71bd64c796b1ce59a46f5c92cfc92472bdeb07ed1542aa2aa50cf8275f59
BLAKE2b-256 checksum
How to use checksums
d7e9f77b4a51ab03aaebdb0045b351f913f231acb8c8af3125b9f251c964262b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for linaldb 0.1.19

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.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for linaldb-0.1.19-cp39-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

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