sqlfs
fsspec adapter backed by SQL.
sqlfs exposes a single node table as an fsspec filesystem (protocol = "sql").
Paths form a tree and file bodies are stored as JSON. Works over SQLite and
PostgreSQL via SQLAlchemy async drivers.
Installation
pip install joha-sqlfs
Or with uv:
uv add joha-sqlfs
Development setup
uv sync --group dev
prek install
Current scope
- async filesystem operations via SQLAlchemy
AsyncEngine(AsyncFileSystem) - path CRUD via
_pipe_file/_cat_file,_ls,_glob,_rm,_info, … - SQLite (
aiosqlite) and PostgreSQL (asyncpg) backends - file payloads are stored as JSON with
content_type = "application/json" - table creation and migrations stay on the client side
open()/ file-like writers are not fully adapted yet (use pipe/cat)
Schema contract
sqlfs does not create or own the table. The client creates the
fs_node table; after construct, call await fs._setup() to open a connection,
reflect and validate the schema.
Required columns:
pathparenttype(fileordir)content_typecontentsizeatimemtimectime
A minimal SQLite-compatible schema looks like this:
CREATE TABLE fs_node (
path TEXT PRIMARY KEY,
parent TEXT NOT NULL,
type TEXT NOT NULL CHECK (type IN ('file', 'dir')),
content_type TEXT,
content TEXT,
size INTEGER NOT NULL DEFAULT 0,
atime REAL,
mtime REAL,
ctime REAL
);
CREATE INDEX ix_fs_node_parent ON fs_node(parent);
For PostgreSQL, content can be a JSON-capable type such as JSONB.
Usage
Use an async SQLAlchemy URL (sqlite+aiosqlite://… or
postgresql+asyncpg://…). Construct is sync; schema load and I/O are async:
import asyncio
import fsspec
from sqlfs import SQLFileSystem
fsspec.register_implementation("sql", SQLFileSystem)
async def main() -> None:
fs = fsspec.filesystem(
"sql",
url="sqlite+aiosqlite:///app.db",
# or "postgresql+asyncpg://user:pass@host/db"
table="fs_node",
asynchronous=True,
)
await fs._setup()
await fs._pipe_file("/cv/1/data", b'{"name": "John Doe"}')
print(await fs._cat_file("/cv/1/data")) # b'{"name": "John Doe"}'
print(await fs._ls("/cv", detail=False)) # ["/cv/1"]
print(await fs._glob("/cv/*/data")) # ["/cv/1/data"]
await fs._close_conn()
asyncio.run(main())
Tests
uv run pytest
The PostgreSQL test cases use testcontainers and require Docker.
Metadata
Release files for joha-sqlfs 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| joha_sqlfs-0.2.0.tar.gz | 99.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| joha_sqlfs-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.5 kB
Release files / joha_sqlfs-0.2.0.tar.gz
| Download URL | joha_sqlfs-0.2.0.tar.gz |
|---|---|
| Size | 99.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97b134ed516f21481a89ef5bab50fb1fd7547555fe3ab9d94e22e3a03e4d129d
|
|
BLAKE2b-256 checksum How to use checksums |
413db870c38348efd7e2168361669fc44ea2caa1e0dde7cbab0197e06387e869
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / joha_sqlfs-0.2.0-py3-none-any.whl
| Download URL | joha_sqlfs-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f73a3ed2b73b0d483d6d66e4536ab7ece277f74951ef9d92b1f273b39e5fe73
|
|
BLAKE2b-256 checksum How to use checksums |
e25b3127535e4c3af94a71b2321899e205c3ce1394c51aa3476eed7284ab4e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for joha-sqlfs 0.2.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.