LogoLogo
vBase.comvBase App
  • Welcome
    • Welcome to vBase
    • Unique Advantages
    • Core Concepts
      • How vBase Works
      • What is a Stamp?
      • Technical Overview
      • Why Blockchains?
    • Example Use Cases
  • Getting Started
    • Start your Journey
    • Stamping Best Practices
    • Python Quickstart
      • Cloud Notebooks
      • Local Installation
  • Web Tools
    • Stamp an Object
    • Verify an Object
  • Use Case How-Tos
    • Verified Investment Track Records
  • Python SDK
    • Samples
      • Creating a Dataset
      • Adding a Dataset Record
      • Adding a Dataset Record Asynchronously
      • Restoring Dataset Provenance
      • Stamp Interactive Brokers Portfolio
      • Stamp Alpaca Portfolio
    • Windows Setup Guide
    • Package vbase-py
    • Package vbase-py-tools
      • Setup
      • commit_s3_objects
      • verify_s3_objects
  • Other SDKs
    • COM Library Overview
    • Working in Excel
      • Via vBase Workbook
      • Via Excel VBA
    • COM API Reference
    • C#
    • TypeScript
  • Technical Reference
    • Command Line Interface
    • Windows Subsystem for Linux (WSL) Guide
    • GCE S3 Compatible Bucket Setup
    • Smart Contract Addresses
Powered by GitBook
On this page
  • Summary
  • Detailed Description
  1. Python SDK
  2. Samples

Adding a Dataset Record Asynchronously

PreviousAdding a Dataset RecordNextRestoring Dataset Provenance

Last updated 1 month ago

This sample creates a dataset comprising string records if one does not exist and adds a record to the dataset. The sample uses async methods to commit a dataset and records and illustrates async operation using asyncio.

You can find the implementation in .

Summary

A set is a collection of objects. A named set of data records is a dataset. Such datasets can implement any point-in-time (PIT) or bitemporal data and prove this provenance to third parties. The sample demonstrates the higher-order async vBase dataset and string record abstractions that hide the details of the object and record content id (CID) calculation (hashing). This example builds on the add_string_dataset_record.py code and illustrates async methods.

Detailed Description

  • Create a vBase object using a Web3 HTTP commitment service. The commitment service is a smart contract running on a blockchain. The initialization uses connection parameters specified in environment variables:

    vbc = VBaseClient.create_instance_from_env()
  • Create the test dataset asynchronously. This factory method constructs a VBaseDatasetAsync object using the asyncio event loop. Arguments and mechanics are similar to those of VBaseDataset object creation.

    VBaseDatasetAsync.create(vbc, name=SET_NAME, record_type=VBaseStringObject)
  • Add string record to the dataset asynchronously. This method makes an object commitment using the asyncio event loop. Arguments and mechanics are similar to those of ds.add_record() call:

    ds.add_record_async("TestRecord")
  • Verify that a given set commitment exists for a given user. This will typically be called by the data consumer to verify a producer’s claims about dataset provenance:

    assert ds.verify_commitments()[0]
add_string_dataset_record_async.py