haadb
Hive-as-a-DB SDK for Python.
Leveraging Hive custom JSONs to store both text-based and binary data. Hive Custom JSONs are limited to 4096 KB includng overheads, HaaDB breaks data into chunks whenever required.
When using objects such as images, files, etc., make sure you have processed it into hex-strings, for example, else it might use class names, pointers, or other data that may result to data loss.
Official Release
HaaDB can now be used on your Python projects through PyPi by running pip command on a Python-ready environment.
pip install haadb --U
Current version is 1.0.*, but more updates are coming soon.
This is compatible with Python 3.9 or later.
WARNINGS:
- This package is still under development, some future breakage is inevitable.
- All
writetransactions in the Hive Blockchain incurs RC costs. - Do NOT copy your private keys in your codes!
HaaDB Modules.
WARNING: Store WIFs securely in a separate file!
Import Module
from haadb import HaaDB
Initialization
# Warning: Do NOT store your WIFs in the code,
# or in the repository!
username = "valid-username"
wifs = { "active": "5*" , "posting": "5*"}
# `limit` --> bytes size before the string representation
# before the string is sliced into chunks, 1024-4096 (default 4096)
limit = 1024
# basic usage
db = HaaDB(username, wifs=wifs, limit=limit)
Optimization
Get the last known transaction id and store in your app configuration. This will optimize the traversal in the account history.
marker = hive.get_marker()
Encryption
Generate a unique encryption key and store securely, to avoid data loss. You can create separate encryption keys for different contracts, or depending on your needs.
ek = hive.generate_encryption_key()
Broadcasting unencrypted data using custom JSONs
cid = "store-integers-v1"
data = 1234567890
hive.broadcast(cid, data)
Fetching unencrypted data (all versions)
cid = "store-integers-v1"
result = hive.fetch(cid, start=marker, latest=False)
for timestamp, content in result.items():
print(timestamp, content)
Fetching unencrypted data (latest version)
cid = "store-integers-v1"
result = hive.fetch(cid, start=marker)
print("\nResult:", result, type(result))
Broadcasting encrypted data using custom JSONs
cid = "store_encrypted_string_v1"
data = "Lorem ipsum, this is a secret message..."
hive.broadcast(cid, data, encryption_key=ek)
Fetching encrypted data (all versions)
cid = "store_encrypted_string_v1"
result = hive.fetch(cid, encryption_key=ek, start=marker, latest=False)
for timestamp, content in result.items():
print(timestamp, content)
Fetching encrypted data (latest versions)
cid = "store_encrypted_string_v1"
result = hive.fetch(cid, encryption_key=ek, start=marker)
print("\nResult:", result, type(result)
Lists, dictionaries, and other objects.
All native data types can be converted back, but other objects will be returned as string representation instead.
cid = "native_list_v1"
data = [1, "2", 3.4]
hive.broadcast(cid, data, encryption_key=ek)
result = hive.fetch(cid, encryption_key=ek, start=marker)
print("\nResult:", result, type(result)
cid = "native_dict_v1"
data = { "message": "Hello, world!"}
hive.broadcast(cid, data, encryption_key=ek)
result = hive.fetch(cid, encryption_key=ek, start=marker)
print("\nResult:", result, type(result)
Metadata
Release files for haadb 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 |
|---|---|---|---|---|
| haadb-1.0.0.tar.gz | 6.2 kB | Without provenance | Details for haadb-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| haadb-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for haadb-1.0.0-py3-none-any.whl |
Total release size: 12.7 kB
Release files / haadb-1.0.0.tar.gz
| Download URL | haadb-1.0.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c62579a389d463879933db3822a793ab116112cf1be9e0ba7cd50132d773521
|
|
BLAKE2b-256 checksum How to use checksums |
5d42d4024549ec2e6285405994700781b0677e778043e78ce7bd719b8e63b0d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Release files / haadb-1.0.0-py3-none-any.whl
| Download URL | haadb-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
771eb637f365bcf8c6c4b261c4a7b944b170c36f22bfafe04d055d55b4d97abf
|
|
BLAKE2b-256 checksum How to use checksums |
e95b286667db03a9db85fb46de14458e554916f96538bd178a88aa0b1c9b3908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.0
|
Security for haadb 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.