Skip to main content

dirsql (Python SDK)

Ephemeral SQL index over a local directory. dirsql watches a filesystem, ingests structured files into an in-memory SQLite database, and exposes a SQL query interface -- the filesystem is always the source of truth.

Documentation

Also available as dirsql on crates.io and dirsql on npm.

Installation

pip install dirsql

Requires Python >= 3.12. Ships as a native extension (Rust via PyO3); prebuilt binary wheels are provided for common platforms.

Quick start

DirSQL is async by default: the constructor returns immediately, scanning runs in a background thread, and you await db.ready() before querying. Each table is a (ddl, glob, extract) triple: the DDL defines the SQLite schema, the glob selects files (relative to the root), and extract turns a matched file into a list of row dicts. dirsql does not read file contents -- if extract needs the file body it reads path itself; return an empty list to skip a file.

import asyncio
import json
from dirsql import DirSQL, Table

async def main():
    db = DirSQL(
        "./my-blog",
        tables=[
            Table(
                ddl="CREATE TABLE posts (title TEXT, author TEXT)",
                glob="posts/*.json",
                extract=lambda path: [json.loads(open(path, encoding="utf-8").read())],
            ),
        ],
    )
    await db.ready()

    posts = await db.query("SELECT * FROM posts WHERE author = 'alice'")
    print(posts)

asyncio.run(main())

Multiple tables and joins

db = DirSQL(
    "./my-blog",
    tables=[
        Table(
            ddl="CREATE TABLE posts (title TEXT, author_id TEXT)",
            glob="posts/*.json",
            extract=lambda path: [json.loads(open(path, encoding="utf-8").read())],
        ),
        Table(
            ddl="CREATE TABLE authors (id TEXT, name TEXT)",
            glob="authors/*.json",
            extract=lambda path: [json.loads(open(path, encoding="utf-8").read())],
        ),
    ],
)
await db.ready()

results = await db.query("""
    SELECT posts.title, authors.name
    FROM posts JOIN authors ON posts.author_id = authors.id
""")

Ignoring files

Pass ignore patterns to skip files during scanning and watching:

db = DirSQL(
    "./my-blog",
    ignore=["**/drafts/**", "**/.git/**"],
    tables=[...],
)

Path-table scans (SELECT ... FROM './') respect .gitignore files by default. Pass no_ignore=True to restore the full walk; the built-in .git default and any ignore patterns still apply:

db = DirSQL("./my-blog", no_ignore=True)

Loading SQLite extensions

Pass extensions to load SQLite extension shared libraries onto the connection at startup (before any CREATE TABLE). Each entry is a dict with a path and an optional entrypoint init-symbol override:

db = DirSQL(
    "./my-blog",
    tables=[...],
    extensions=[
        {"path": "./ext/vec0.dylib", "entrypoint": "sqlite3_vec_init"},
        {"path": "./ext/myext.so"},  # entrypoint derived from the filename
    ],
)
await db.ready()

# The extension's functions are now callable in queries:
rows = await db.query("SELECT vec_version() AS v")

dirsql enables extension loading only while loading the configured libraries, then disables it again, so the SQL load_extension() function is never exposed to your queries. Programmatic entries load first, followed by any [[dirsql.extension]] entries declared in a config file. See the config reference.

Watching for changes

db.watch() returns an async iterator of row-level change events as files change on disk:

async for event in db.watch():
    print(f"{event.action} on {event.table}: {event.row}")
    if event.action == "error":
        print(f"  error: {event.error}")

Each event has .action ("insert", "update", "delete", or "error"), .table, .row (the new row, or the deleted row on delete), .old_row (the previous row, on update), .file_path, and .error (on error).

CLI

pip install dirsql also installs a dirsql console script. dirsql "<sql>" (or uvx dirsql "<sql>") runs one query and prints the rows as JSON — the default. dirsql server starts an HTTP server exposing the SDK over HTTP: POST /query for SQL and GET /events for a Server-Sent Events change stream. See the CLI reference.

License

MIT

Metadata

Release files for dirsql 0.4.130

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

Source distribution (sdist)

Source distribution for dirsql 0.4.130
File Size Uploaded Provenance Actions
dirsql-0.4.130.tar.gz 723.4 kB With provenance Details for dirsql-0.4.130.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for dirsql 0.4.130
File Actions
dirsql-0.4.130-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for dirsql-0.4.130-cp310-abi3-win_amd64.whl
dirsql-0.4.130-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for dirsql-0.4.130-cp310-abi3-manylinux_2_28_x86_64.whl
dirsql-0.4.130-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for dirsql-0.4.130-cp310-abi3-manylinux_2_28_aarch64.whl
dirsql-0.4.130-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for dirsql-0.4.130-cp310-abi3-macosx_11_0_arm64.whl
dirsql-0.4.130-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for dirsql-0.4.130-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 19.0 MB

Release files / dirsql-0.4.130.tar.gz

Download URL dirsql-0.4.130.tar.gz
Size 723.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8726925e76368b5a9f467af2008c3957c72bd716c9115f645ede53f9a14fa0c8
BLAKE2b-256 checksum
How to use checksums
4c133f7d4f48b7addebbf5d47efc1076dc5cb7c69e0f1a90d90bb84c9bf0ead1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / dirsql-0.4.130-cp310-abi3-win_amd64.whl

Download URL dirsql-0.4.130-cp310-abi3-win_amd64.whl
Size 3.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1c45a53527e19f54aa7752a3fe06931d5cdc1c45cc47d111f4d80243be15bc06
BLAKE2b-256 checksum
How to use checksums
66f3b9503e0284e459e6f2273a131aa7eea9719744ab32bf47baf14622dabd8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / dirsql-0.4.130-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL dirsql-0.4.130-cp310-abi3-manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
21269d5fb7a155ec717aa1fee744cb8a5a07f1f7ee56ea2201f311e458ea2db3
BLAKE2b-256 checksum
How to use checksums
e2e7b6df9fd3c7793326fbe78c4e0cda4165a8f66f2a9263d98c0b1d66544878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / dirsql-0.4.130-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL dirsql-0.4.130-cp310-abi3-manylinux_2_28_aarch64.whl
Size 3.6 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
bf2d37411fbd55dc03ef0dc514c48ee68f174404eaf0a89047c26401bdc72307
BLAKE2b-256 checksum
How to use checksums
962f8d9877d136364f890be636d8ff6cddfc27c2768e17b5eb5e9fe6889735d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / dirsql-0.4.130-cp310-abi3-macosx_11_0_arm64.whl

Download URL dirsql-0.4.130-cp310-abi3-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cd36a26e250ee3a52fe1e965e3f9178ff0c4cd7672f00808ae4254d358b1caa1
BLAKE2b-256 checksum
How to use checksums
f6d32e47b3728bb9caae9e1a3b0c3901f910deeed7f784b10d7f1e36e4bc16dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / dirsql-0.4.130-cp310-abi3-macosx_10_12_x86_64.whl

Download URL dirsql-0.4.130-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.6 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1b211bc01db5a1b847db4271a4927348442eadc5ba1c57fc22d09fe26a5f1597
BLAKE2b-256 checksum
How to use checksums
fd61884a9b08dd40aa0b2754f89e0c723d5ea7a68853cbe4144e1cb1126381c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Security for dirsql 0.4.130

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 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for dirsql-0.4.130.tar.gz

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 Nov 3, 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.

Release history Release notifications | RSS feed

This release

0.4.130 This release

6 release files Full provenance

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