blockpoint Systems - MultiVersion Database (MDB) ODBC
Project description
mdb-bp
Table of Contents
This package contains a pure-Python MDB client library.
Requirements
- Python >= 3.9.0
- MDB >= 1.0
Installation
Package is uploaded on PyPI.
Install with pip:
$ python3 -m pip install mdb-bp
Documentation
bSQL documentation is available online:https://bsql.org/
For support, please refer to StackOverflow.
Example
The following example makes use of a simple blockchain, inserts a value, and reads that value.
from mdb_bp import driver
# Connect to the database
conn = driver.connect(
username="user",
password="password",
connection_protocol="tcp",
server_address="216.27.61.137",
server_port=8080,
database_name="master",
parameters={"interpolateParams": True},
)
# Prepare a statement
stmt = conn.prepare(
"CREATE BLOCKCHAIN user TRADITIONAL ("
+ "id uint64 PRIMARY KEY AUTO INCREMENT,"
+ " first_name string size = 25 PACKED,"
+ " last_name string size = 50 PACKED,"
+ " age uint8,"
+ " username string size=30 PACKED UNIQUE)")
# Execute the statement.
resp = stmt.exec()
print(resp)
# Run an insertion and handle error
xact = conn.begin()
# Insert a value non-atomically
try:
result = xact.exec(
"INSERT user (first_name, last_name, age, username) "
+ "VALUES (\"it's NOT CHABOY\", \"Smith\", 45, \"NOT CHABOY\")")
print(result)
xact.commit()
except Exception as err:
# Rollback the transaction if there was a failure
print(err)
xact.rollback()
# Query from the blockchain
rows = conn.query("SELECT * FROM user")
# Print the rows
itr = iter(rows)
for row in itr:
print(row)
# Store a file
store_file_resp = conn.store_file(
"space",
"test_files/space.png",
"png"
)
print(store_file_resp)
# Export a file
export_file_resp = conn.export_file(
"space",
"test_files/out_space.png",
"png"
)
print(export_file_resp)
Resources
- bSQL documentation: https://bsql.org/
- DB-API 2.0: https://www.python.org/dev/peps/pep-0249/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mdb_bp-1.0.3.tar.gz
(20.9 kB
view details)
File details
Details for the file mdb_bp-1.0.3.tar.gz
.
File metadata
- Download URL: mdb_bp-1.0.3.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 411803e294c1f37f4b10996128153df54eb820f1be2269831a84848b5dc21ae9 |
|
MD5 | c1278d781b1a5e8d6af591609683ffac |
|
BLAKE2b-256 | 54a925ce2bdf61dccb314134010aa1dadac6eae9ab61c9e14eb60ac0ca79741b |