Skip to main content

b4n1-db — Python SDK

Sovereign embedded data layer. Eight local storage engines behind one file directory — key-value, SQL, graph, documents, queues, vectors, audit and migrations — plus transfer, with no server, no daemon and no network round trip.

The Python package is a thin wrapper: every operation is executed by the b4n1-db engine that ships precompiled inside the wheel for your platform. No compiler, no build step, no separate service to install.

Install

pip install b4n1-db

Wheels are published for Linux (x86_64, arm64), macOS (Intel, Apple silicon) and Windows x86_64. If no wheel matches your platform, pip fails instead of handing you a wrapper that cannot run.

Quick start

from b4n1db import DB

db = DB("./data")

db.kv.put("greeting", "hello")
print(db.kv.get("greeting"))        # {'key': 'greeting', 'value': 'hello'}

db.sql.execute("CREATE TABLE users (id BIGINT, name VARCHAR)")
db.sql.execute("INSERT INTO users VALUES (1, 'ada')")
print(db.sql.query("SELECT name FROM users"))   # {'columns': [...], 'rows': [...]}

node = db.graph.add_node("pattern", "ada")      # {'ok': True, 'id': '…'}
db.doc.insert("notes", {"text": "first"})
db.queue.push("jobs", "build")
db.audit.verify()

print(db.stats())                   # {'current_version': 0, 'kv_entries': 2, 'merkle_nodes': 2}

The nine engines

Every engine of the binary is a group on the handle:

Group Methods
db.kv put get delete scan put_ttl ttl purge_expired
db.sql execute query tables register_csv register_json register_parquet drop
db.graph add_node add_relation node search forget
db.doc insert find_one find find_by_field update delete
db.queue push pop peek ack nack clear len
db.vector insert search delete list
db.audit verify history latest time_travel root_hash
db.migration list add apply exec rollback
db.transfer backup restore export import_

Three details worth knowing before they surprise you:

  • Vectors have one dimension per database, 1536 by default. A list of another length is refused (Vector dimension mismatch), never padded.
  • Graph nodes are typed: instruction, intention, contract, pattern, scaffold, qapair, cyclerecord (db.graph.NODE_TYPES).
  • Mutations answer with facts, not sentences: {'ok': True, 'id': '…'}, {'ok': True, 'rows_affected': 1}. A missing key raises RuntimeError carrying the engine's typed error instead of returning None.

db.kv_put, db.kv_get, db.stats and db.demo remain as the flat aliases from 0.1.

Where the data lives

The database is a directory, not a single file:

data/
├── sled/          # keys, queues, vectors
├── sql/           # tables, as Arrow IPC
├── merkle/        # the audit DAG
└── migrations/    # the schema registry

Copy the whole folder to back it up, or use db.transfer.export(path) for a portable JSON Lines dump. There is no server and no port to open, but nothing locks the directory either: one process per database directory.

The engine behind it

The same binary is a complete command-line client, so nothing is hidden behind the wrapper:

b4n1-db --db ./data stats
b4n1-db --db ./data sql execute "SELECT name FROM users"
b4n1-db --db ./data docs            # the full reference, offline

B4N1_DB_BIN=/path/to/b4n1-db points the wrapper at a specific binary when you want to run a build of your own instead of the bundled one.

Try it in one command

python -m b4n1db demo

The demo runs against a throwaway database, prints each capability with live numbers, and touches nothing of yours.

Documentation

SDKs in other languages

b4n1-db ships a wrapper for JavaScript, C#, Ruby, PHP and Go, each with the same nine groups and the same fifty methods. Each one carries the same contract: the platform binary does the work, the wrapper only marshals arguments.

License

Wrappers: Business Source License 1.1 (LICENSE). Precompiled binaries: B4N1 End User License Agreement (EULA.txt).

Metadata

Release files for b4n1-db 0.1.2

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 b4n1-db 0.1.2
File Actions
b4n1_db-0.1.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for b4n1_db-0.1.2-py3-none-win_amd64.whl
b4n1_db-0.1.2-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for b4n1_db-0.1.2-py3-none-manylinux_2_17_x86_64.whl
b4n1_db-0.1.2-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for b4n1_db-0.1.2-py3-none-manylinux_2_17_aarch64.whl
b4n1_db-0.1.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for b4n1_db-0.1.2-py3-none-macosx_11_0_arm64.whl
b4n1_db-0.1.2-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details for b4n1_db-0.1.2-py3-none-macosx_10_13_x86_64.whl

Total release size: 116.0 MB

Release files / b4n1_db-0.1.2-py3-none-win_amd64.whl

Download URL b4n1_db-0.1.2-py3-none-win_amd64.whl
Size 24.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
123beca9a8b5dc9b96e5e113b5473d8b7141c9603a2727e55f49e0e7bcb3ecb3
BLAKE2b-256 checksum
How to use checksums
2fe6fdaeb1d6637de41e6ea001d72c38c115b8ff06f20495ab26928f89ab8e38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / b4n1_db-0.1.2-py3-none-manylinux_2_17_x86_64.whl

Download URL b4n1_db-0.1.2-py3-none-manylinux_2_17_x86_64.whl
Size 24.1 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
4e72659ae7c55e3e7fd40d8ba56789962db0d02c98fd554ef8e0afaf7eb09e8b
BLAKE2b-256 checksum
How to use checksums
172a7f1c4efd86cffd2fce6df3d78ec3f959f3e20b1f644205810118fd6d723d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / b4n1_db-0.1.2-py3-none-manylinux_2_17_aarch64.whl

Download URL b4n1_db-0.1.2-py3-none-manylinux_2_17_aarch64.whl
Size 22.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2812a9db9307e1da554ab6277840d9ce17776dc657cd6dcf7610cbfbdc0098ac
BLAKE2b-256 checksum
How to use checksums
de9cc273bf5c05c03d419a3f5aab76b3bcfedd6b834c7aa5cfc19ca6aee29b3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / b4n1_db-0.1.2-py3-none-macosx_11_0_arm64.whl

Download URL b4n1_db-0.1.2-py3-none-macosx_11_0_arm64.whl
Size 21.7 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c0916fc7785abeccc8d4ff495ca7565af9955cc076347c628621282f97b1f6d
BLAKE2b-256 checksum
How to use checksums
c2d5f56e991226c169f42de555a9b1e465a11b47efaa201bcb8c9b6d3f887c75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / b4n1_db-0.1.2-py3-none-macosx_10_13_x86_64.whl

Download URL b4n1_db-0.1.2-py3-none-macosx_10_13_x86_64.whl
Size 23.7 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
5f09d4134a93452c6b285038f07cc817297595dbc5f7f45ed2db7fe7213e59a4
BLAKE2b-256 checksum
How to use checksums
6e6a653644fa6f67aad9e1a7b7c54db18b00ad0738588951bc72650f69d22e2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for b4n1-db 0.1.2

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.

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