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

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

Total release size: 106.0 MB

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

Download URL b4n1_db-0.1.4-py3-none-win_amd64.whl
Size 21.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
b400dec20c04846df3759999969fd7936f7902a2298f930b7a11951c136cfd09
BLAKE2b-256 checksum
How to use checksums
e4b6f2fa4ca9348da9eaca5b2ebb99c73ae4488b4ae8af10076aa84533e4f307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

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

Download URL b4n1_db-0.1.4-py3-none-manylinux_2_17_x86_64.whl
Size 21.5 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b20da5aa97d0a2cc6b7bc9ffae09aadc8f7f25372e5c93e1287858e958d78da9
BLAKE2b-256 checksum
How to use checksums
ae3813d4f999dcbf88962ef2343865f2dc02d8da269d5ce57fe3632f0c4c8224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

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

Download URL b4n1_db-0.1.4-py3-none-manylinux_2_17_aarch64.whl
Size 21.4 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
79c71578352da80d99e94cc743cf6d5de20dfb82cc99bbd26a5aa5e416b65ae2
BLAKE2b-256 checksum
How to use checksums
8794878dfd24d7beb9d4ea6818857b5bb0669ebf4c474b18017f7a52fd42f613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

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

Download URL b4n1_db-0.1.4-py3-none-macosx_11_0_arm64.whl
Size 20.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
820920fa4353b4e4b2857a3eee64b5008518f9d3ebc86d1003f31905efdd6b5c
BLAKE2b-256 checksum
How to use checksums
8f09d77dfb0bbc7bc80a16c3fd542803cad981a82e69ebe1baf0b40163bafc8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

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

Download URL b4n1_db-0.1.4-py3-none-macosx_10_13_x86_64.whl
Size 21.2 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
d5329617e5d0cb950d31933cfddada335450aa68cf62513301827dc8b3b2f828
BLAKE2b-256 checksum
How to use checksums
15acd0f8cf2c1fad59de58484395fafecbded845c78bb0c6064716ee2bc3c849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / b4n1_db-0.1.4-py3-none-any.whl

Download URL b4n1_db-0.1.4-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41a2a5dcd5e50fae57fe866515ae073a2125d060c4ec2a5173d25f23f6322ed4
BLAKE2b-256 checksum
How to use checksums
c6f0eba2a34e573335f84049419a0fa00cfbd6e813650496f978708d8ab2d9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for b4n1-db 0.1.4

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