UNPChainDatabaseSDK — Python
A generic, encrypted, blockchain-backed database SDK for the UNP Chain.
Store, retrieve, update, and delete any JSON-serializable Python object on-chain with private-key-based AES-256-GCM encryption.
Installation
pip install unpchain-database-sdk
Quick Start
from unpchain_database_sdk import ChainDatabase, ChainDatabaseOptions
# With MongoDB (recommended)
options = ChainDatabaseOptions(
mongo_connection_string="mongodb://localhost:27017",
mongo_database_name="MyApp",
)
db = ChainDatabase("0xYOUR_PRIVATE_KEY", "Product", options)
# Insert
result = db.insert({"name": "Keyboard", "price": 149.99})
print(result.tx_hash) # on-chain proof
print(result.payload) # encrypted blob (store this!)
# Read
product = db.get(result.payload)
# Update
result2 = db.update(result.payload, result.tx_hash, {"name": "Keyboard", "price": 129.99})
# Delete
db.delete(result2.payload, result2.tx_hash)
# MongoDB-backed convenience methods
all_records = db.get_all()
record = db.get_by_record_id("some-record-id")
db.update_by_record_id("some-record-id", new_data)
db.delete_by_record_id("some-record-id")
Without MongoDB
db = ChainDatabase("0xYOUR_PRIVATE_KEY", "Product")
result = db.insert({"name": "Keyboard", "price": 149.99})
# You must store result.tx_hash and result.payload yourself!
product = db.get(result.payload)
API Reference
| Method | MongoDB Required | Description |
|---|---|---|
insert(data) |
No | Encrypt + store on-chain |
update(payload, tx_hash, new_data) |
No | Chain a new version |
delete(payload, tx_hash) |
No | Soft-delete on-chain |
get(payload) |
No | Decrypt → data (None if deleted) |
get_record(payload) |
No | Decrypt → RecordInfo with metadata |
is_deleted(payload) |
No | Check soft-delete flag |
get_all(sort_order) |
Yes | All records for this wallet |
get_by_record_id(id) |
Yes | Single record by stable GUID |
update_by_record_id(id, data) |
Yes | Convenience update |
delete_by_record_id(id) |
Yes | Convenience delete |
Testing
cd tests
python test_integration.py
Metadata
Release files for unpchain-database-sdk 1.0.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 | Actions |
|---|---|---|---|---|
| unpchain_database_sdk-1.0.0.tar.gz | 12.1 kB | Without provenance | Details for unpchain_database_sdk-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unpchain_database_sdk-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for unpchain_database_sdk-1.0.0-py3-none-any.whl |
Total release size: 24.6 kB
Release files / unpchain_database_sdk-1.0.0.tar.gz
| Download URL | unpchain_database_sdk-1.0.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9713bec359039eeea241917185c1a5a7c4768d3aa2337600310deaa535364d51
|
|
BLAKE2b-256 checksum How to use checksums |
43e1ec03b2ac82603d090e273ee85768186e5a1df1aa8f7514c4916c68670d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / unpchain_database_sdk-1.0.0-py3-none-any.whl
| Download URL | unpchain_database_sdk-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2215cf03da3aa08b85ae5306df8f7edaf2aa9113ef53230ecb9dc63ecbde0785
|
|
BLAKE2b-256 checksum How to use checksums |
61848281afd6b8a5f55809c72fa44b80c1c224a56e7782c96aa879423552a306
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for unpchain-database-sdk 1.0.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.