A generic, encrypted, blockchain-backed database SDK for the UNP Chain.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unpchain_database_sdk-1.0.0.tar.gz.
File metadata
- Download URL: unpchain_database_sdk-1.0.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9713bec359039eeea241917185c1a5a7c4768d3aa2337600310deaa535364d51
|
|
| MD5 |
f316c2e58acbf87013175fa91369e9b4
|
|
| BLAKE2b-256 |
43e1ec03b2ac82603d090e273ee85768186e5a1df1aa8f7514c4916c68670d99
|
File details
Details for the file unpchain_database_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unpchain_database_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2215cf03da3aa08b85ae5306df8f7edaf2aa9113ef53230ecb9dc63ecbde0785
|
|
| MD5 |
55e354d1807011e1be44a7e612c4c7c9
|
|
| BLAKE2b-256 |
61848281afd6b8a5f55809c72fa44b80c1c224a56e7782c96aa879423552a306
|