dirsql
Ephemeral SQL index over a local directory
What it is and what it does
dirsql is a Python SDK that creates an ephemeral SQL interface over a filesystem directory. It watches for file changes, ingests structured files (JSON, etc.) into an in-memory SQLite database according to user-defined schemas and glob patterns, and exposes standard SQL queries. The filesystem remains the source of truth; the database is rebuilt from files on startup and kept in sync via background file watching.
You define tables by specifying DDL, a glob pattern to select files, and an extraction function that converts matched files into row dicts. dirsql handles the scanning and indexing asynchronously; you await db.ready() before querying. It supports multiple tables, joins, SQLite extensions, and an async iterator for row-level change events (insert, update, delete). A CLI tool is also included for one-off queries and an HTTP server mode.
Use it for:
- Query a blog directory (posts and authors as JSON files) with SQL joins across tables
- Monitor a config directory for changes and react to inserts/updates/deletes via async events
- Index structured logs or data files and run ad-hoc SQL analysis without a separate database
- Load SQLite extensions and use them in queries over filesystem data
- Expose filesystem data over HTTP via the built-in server for remote SQL access
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Watches a local directory, indexes structured files into an in-memory SQLite database, and exposes a SQL query interface with real-time change tracking.
Yes, if you need to query structured files in a directory with SQL and want real-time change tracking. The native extension adds medium install friction but provides prebuilt wheels for common platforms. MIT license and active maintenance are favorable. No known vulnerabilities. Suitable for development, data analysis, and small-to-medium workloads.
Install
dirsql on PyPI
pip
pip install dirsqluv
uv add dirsqlpoetry
poetry add dirsqlInstalling dirsql
Before you install
Medium install friction due to native Rust extension; prebuilt wheels cover common platforms (macOS x86_64/arm64, Linux x86_64/aarch64, Windows x64). Requires Python >= 3.10. Active maintenance with recent releases.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install dirsql
import asyncio
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: [__import__('json').loads(open(path).read())])])
await db.ready()
posts = await db.query("SELECT * FROM posts WHERE author = 'alice'")
print(posts)
asyncio.run(main())
Requires Python >= 3.10. Ships as native Rust extension; prebuilt wheels provided for macOS (x86_64, arm64), Linux (x86_64, aarch64), and Windows (x64).
Verify before relying
- Performance characteristics for large directories or complex joins not specified
- Memory overhead for in-memory SQLite index relative to directory size not quantified
- Behavior when files are deleted or moved during active queries not documented
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — tomli, bin-shim |
| Maintenance | actively maintained — 2 days since the last release |
| First released | |
| Downloads | 176,965/month — #10,228 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dirsql-0.4.20-cp310-abi3-macosx_10_12_x86_64.whl; dirsql-0.4.20-cp310-abi3-macosx_11_0_arm64.whl; dirsql-0.4.20-cp310-abi3-manylinux_2_39_aarch64.whl; dirsql-0.4.20-cp310-abi3-manylinux_2_39_x86_64.whl; dirsql-0.4.20-cp310-abi3-win_amd64.whl
Keywords: sql, filesystem, directory, sqlite, index
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
libsql-clientPython SDK for connecting to and querying…
permissive · top 15,000 on PyPI
osqueryPython bindings for creating osquery extensions…
permissive · top 15,000 on PyPI
aiosqliteaiosqlite provides an async interface to SQLite…
permissive · top 1,000 on PyPI
sqlite-utilsCLI tool and Python library for creating,…
permissive · top 5,000 on PyPI
aiosqlLoad SQL queries from files and call them as…
permissive · top 15,000 on PyPI
qpdQPD translates SQL SELECT statements into…
permissive · top 15,000 on PyPI
dirsyncSynchronizes, updates, or reports differences…
permissive · top 15,000 on PyPI
sqlitedictProvides a dict-like interface to SQLite…
permissive · top 5,000 on PyPI
apswutilsProvides a Python interface for SQLite…
permissive · top 15,000 on PyPI
fastlitefastlite wraps sqlite-utils to provide…
permissive · top 15,000 on PyPI