🐻📚 Bear-Shelf
The shelf where your data hibernates. 🐻💤
A lightweight document storage system with SQLAlchemy dialect support. Store your data in JSONL, JSON, TOML, YAML, XML, MessagePack, or in-memory formats with a clean, type-safe interface — no SQLite required.
Features
- 🔌 SQLAlchemy Integration: A real SQLAlchemy dialect — use familiar ORM syntax over plain files
- 📦 Multiple Backends: JSONL (default), JSON, TOML, YAML, XML, MessagePack, or in-memory
- 🧰 Two Front Doors: Use the raw
bearshelf://dialect, or the batteries-includedDatabaseManagerAPI - 🔒 Type-Safe: Full type hints, Pydantic models, and custom column types (
Mapped[Path],Mapped[EpochTimestamp]) - 📝 Write-Ahead Logging: Optional WAL with buffered/immediate flush modes for durability and bulk-write speed
- ⚡ Compiled Core: Hot paths implemented in C++23 with pybind11; TOML encoding uses Fond's insertion-ordered toml++
Installation
With uv:
uv add bear-shelf
# or
uv pip install bear-shelf
Minimum Python: 3.13.
Building and releasing wheels
pyproject.toml is the package-version source of truth. The build generates
bear_shelf._internal.version from that version; importing the library does not
query Git or scan installed packages. There is no package CLI.
mask build
Releases are wheel-only. After committing your changes, mask bump patch
(or minor / major) uses uv version --bump, builds the wheel, commits the
version files, and atomically pushes the release commit and tag. A failed build
stops before committing or tagging.
Quick Start
Bear-Shelf gives you two equally first-class ways to work with your data. Pick whichever fits how you think.
Option A — Raw SQLAlchemy dialect
If you already know SQLAlchemy, just point an engine at a file. The backend is chosen by the file extension.
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, Session
engine = create_engine("bearshelf:///path/to/users.jsonl")
class Base(DeclarativeBase): ...
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str]
email: Mapped[str] = mapped_column(unique=True)
Base.metadata.create_all(engine)
with Session(engine) as session:
session.add(User(name="Bear", email="bear@shelf.com"))
session.commit()
Option B — DatabaseManager API
A higher-level wrapper that handles the engine, sessions, and table registration for you, and returns convenient per-table handles.
from pathlib import Path
from sqlalchemy.orm import Mapped, mapped_column
from bear_shelf.database import BearShelfDB
# get_base() returns a declarative base wired with Bear-Shelf's custom types
Base = BearShelfDB.get_base()
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str]
config_path: Mapped[Path] # stored as text, returned as a Path
db = BearShelfDB(path="users.jsonl")
# Build only the tables you want; bare create_tables() builds them all.
db.include(User).create_tables()
with db.open_session() as session:
session.add(User(name="Bear", config_path=Path("~/cfg.toml")))
users = db.get_all(User) # [User(name='Bear', ...)]
count = db.count(User) # 1
db.close()
include(*models) is handy when one declarative base defines many tables but a
given database should only create a subset (e.g. test isolation). Creating a
subset whose foreign keys reference tables you left out fails loudly with a
message telling you what to add.
🎨 Custom Column Types
Annotate columns with rich Python types and Bear-Shelf converts them at the storage boundary — no manual (de)serialization:
| Annotation | Stored as | Returned as |
|---|---|---|
Mapped[Path] |
text | pathlib.Path |
Mapped[EpochTimestamp] |
integer | bear_epoch_time.EpochTimestamp |
These are registered on the base returned by BearShelfDB.get_base().
🎯 Storage Backends
The backend is auto-detected from the file extension (or pass storage=/schema=):
| Backend | URL / extension |
|---|---|
| JSONL (default) | bearshelf:///data.jsonl |
| JSON | bearshelf:///data.json |
| TOML | bearshelf:///data.toml |
| YAML | bearshelf:///data.yaml |
| XML | bearshelf:///data.xml |
| MessagePack | bearshelf:///data.msgpack |
| Memory | bearshelf:///:memory: |
📝 Write-Ahead Logging
For bulk writes and crash safety, enable WAL. In BUFFERED mode, inserts append
to a log and a background thread checkpoints to the main file — turning thousands
of slow full-file rewrites into fast appends.
from bear_shelf.datastore import BearBase, Columns
from bear_shelf.datastore.wal.config import WALConfig
db = BearBase(
"events.json",
storage="json",
enable_wal=True,
wal_config=WALConfig.high_throughput(), # or .immediate() for fsync-per-op
)
db.create_table("events", columns=[
Columns(name="id", type="int", primary_key=True),
Columns(name="event_type", type="str"),
])
table = db.table("events")
table.insert_all([{"id": i, "event_type": "click"} for i in range(5000)])
db.close()
See examples/wal_example.py for buffered/immediate
modes, custom tuning, manual checkpointing, and crash recovery, and
examples/foreign_key_example.py for relationships.
🐻 About
Built with ❤️ by Bear. Part of the Bear-verse ecosystem:
funcy_bear: functional programming & type introspection utilitiesbear-epoch-time: precision-aware timestamp handlingcodec_cub: Codec utilties for the various storages used in Bear Shelf
Metadata
Release files for bear-shelf 0.3.36
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 23.1 MB
Release files / bear_shelf-0.3.36-cp315-cp315-win_amd64.whl
| Download URL | bear_shelf-0.3.36-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 148.7 kB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b62c937c1ab48699990a18a3f8a1f9b55ad1beb0e2a097183a5e088a6b9d9c9c
|
|
BLAKE2b-256 checksum How to use checksums |
813e69d86d326ceb595f024062d639ad9f723c847c181028c2fe2cf597a1c5ec
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | bear_shelf-0.3.36-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.15 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9ce4b70b33b93511c8e603dc905052469e1a39aee6ec5fd54931f0f338dc8a94
|
|
BLAKE2b-256 checksum How to use checksums |
9c2bef63efa307cd3c9ba236252be5bbb44dd4463fef303fa6380c3823c6d4d4
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp315-cp315-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | bear_shelf-0.3.36-cp315-cp315-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.15 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
a482ce5adce810b2dfd46625006d5e5150b119b5fb6bdd0f39dfa427d46d99e5
|
|
BLAKE2b-256 checksum How to use checksums |
5306696b06377219d8c963c56c035c1976de9ea471fe95ff88eaa2430d7107bc
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp315-cp315-macosx_11_0_arm64.whl
| Download URL | bear_shelf-0.3.36-cp315-cp315-macosx_11_0_arm64.whl |
|---|---|
| Size | 394.8 kB |
| Tags | CPython 3.15 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
abcc28aae9e9f03403bb33d96e4201790d6abfe1a0a8271cbbc933594193c059
|
|
BLAKE2b-256 checksum How to use checksums |
941987b601c3acbaa76519f08851f494faebfcda7c81d5671662d011ba022bf4
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp314-cp314-win_amd64.whl
| Download URL | bear_shelf-0.3.36-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 148.7 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6a160381de9c1f8c47c69cd20bf1791a76f98274b3ef6a62cd228f45ff741cf9
|
|
BLAKE2b-256 checksum How to use checksums |
4c7ba94c1665a1a919865aa81b4cbd7317a1d00c2555a1a72c7c57f04a8e9cc4
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | bear_shelf-0.3.36-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
36033f572b6a7b6a144414ed985ea79894f75773877854f5759f8122227489b3
|
|
BLAKE2b-256 checksum How to use checksums |
d49ed06796aeb2764ea61f883c860ce3d7f37254e6e424578ac835b5ed595925
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | bear_shelf-0.3.36-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.14 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
c007145c55c5d34e8dfbb07cc45c289a1f75aac14f7eaabc277f5f4e5f46cb1f
|
|
BLAKE2b-256 checksum How to use checksums |
18214b97971a81e4c311d63035805114a274cb8eb76bba9e6aca674a5424826e
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | bear_shelf-0.3.36-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 394.4 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
681441657d15be86d979a90562c59fc4a5d48161228db330b97093e1cbdb44a9
|
|
BLAKE2b-256 checksum How to use checksums |
fce1d4e4fcd6bd1a8f2a2a5ea957ab6746cf4718cfa81b51930803b12dd96384
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp313-cp313-win_amd64.whl
| Download URL | bear_shelf-0.3.36-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 149.0 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a3c55e85e1c4c4fb3471b90441b28b34c5f656a7f4eb4febf9dbcb23fb8dfcee
|
|
BLAKE2b-256 checksum How to use checksums |
23ce71a4b48343ea39b67953e88ad4e0f6ad2f41414efd94d97555905e3a9133
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | bear_shelf-0.3.36-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
e0f271218e0ba36450c6ff0b4010b24ba887180bc6dd48f23ac11be565df4cc0
|
|
BLAKE2b-256 checksum How to use checksums |
fef996192dde46de916875daad20ca2c828cde23cedd4ff8769c7fd0383f1af7
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
| Download URL | bear_shelf-0.3.36-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.13 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
45eb25c11a191d2714fc6ab3c639c7a561229638bbc04b1dd527377b6b9aecc2
|
|
BLAKE2b-256 checksum How to use checksums |
cdfb14ccd14f05d8e9220c83c8d79d87844e5b6034b89226c9e5c030223d0c08
|
| 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 18, 2026.
Transparency logRelease files / bear_shelf-0.3.36-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | bear_shelf-0.3.36-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 393.5 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
16574d1bfe9130fd4bfb1ad542b71fa4a1764bc83cd73539e60b2a2a4e98a6df
|
|
BLAKE2b-256 checksum How to use checksums |
713f897d140b735a2ab5e5c6a171b729d825bb84ea8f7ccd157313523b054125
|
| 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 18, 2026.
Transparency logSecurity for bear-shelf 0.3.36
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 12 files in this release have been uploaded with provenance metadata.
Attestation for bear_shelf-0.3.36-cp315-cp315-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 18, 2026.
Transparency logA 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.