Skip to main content

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

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 hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page