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

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

Total release size: 113.5 MB

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

Download URL b4n1_db-0.1.3-py3-none-win_amd64.whl
Size 24.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
72001c7d80303552a78dd6e835b915e44595aef3f3d95e27684ae9b8b37743a0
BLAKE2b-256 checksum
How to use checksums
c0fb36ef0090a2c3ba82ba8f3b7a5a0b33b9662e636d9b1f9ca8a5495f40154a
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.3-py3-none-manylinux_2_17_x86_64.whl

Download URL b4n1_db-0.1.3-py3-none-manylinux_2_17_x86_64.whl
Size 21.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
a2184e226a28a2ae646c4de3be1c8d8f419214b654a9da4a834dd822029a6092
BLAKE2b-256 checksum
How to use checksums
5a06b425ac5c0ba1b7a3c1bc7afc32ca19291469ac540c9dc9d1a5d214cac6e8
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.3-py3-none-manylinux_2_17_aarch64.whl

Download URL b4n1_db-0.1.3-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
9b2f344b3b502999d2a731b4bff64e73788b292f9312ffe45f54cdab77bb9d1b
BLAKE2b-256 checksum
How to use checksums
15266e2428c90b2dba415f20ebdfe63277078763cd62befde6775b198e2c6c27
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.3-py3-none-macosx_11_0_arm64.whl

Download URL b4n1_db-0.1.3-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
2d152c7d9264b45ff23609220c4d1d2699d98bd3044a277a08c988c6b8c281c7
BLAKE2b-256 checksum
How to use checksums
6594c02a219cadd645d3957df9149fe881a1848ee953ac73794875478db7cf03
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.3-py3-none-macosx_10_13_x86_64.whl

Download URL b4n1_db-0.1.3-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
f28387f9c2f64caf9cea52614036574a64d59683a8fefcb8161553afc183c404
BLAKE2b-256 checksum
How to use checksums
66060bcb2bf9072a33049d2d85319644c93a0a6b6a2c9bed4ad109f3936ebe02
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.3

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