Create Session#

See also

The Vast DB SDK API Documentation is available here.

Introduction#

This notebook provides a foundational setup for interacting with a Vast DB database. We’ll begin by installing and importing the necessary Vast DB SDK. Then, we’ll establish a session with the database using your specific endpoint, access key, and secret key.

By completing these steps, we’ll have a solid starting point for exploring and working with Vast DB in subsequent sections of the notebook.

Prerequisites#

  • Ensure you have followed the setup steps in the Getting Started documentation.

Install and import the Vast DB SDK#

Before doing anything else, we need to import the vastdb api library.

!pip install --quiet vastdb

Next we need to import the vastdb library.

import vastdb

Creating the initial session#

You need to change these to reflect your environment.

# Change these variables to reflect your environment, E.g. 
#
# ENDPOINT = 'http://your_vast_endpoint:12345'
# DATABASE_NAME = 'your_db'
# ACCESS_KEY = 'your_access_key'
# SECRET_KEY = 'your_secret_key'

We can then connect to the database.

import vastdb

session = vastdb.connect(
    endpoint=ENDPOINT,
    access=ACCESS_KEY,
    secret=SECRET_KEY)

It can be useful to know the Vast Database cluster version. Let’s print it out.

print("Vast Cluster version: ", session.api.vast_version)

Finally test we can access the database and print out the schemas.

with session.transaction() as tx:
    bucket = tx.bucket(DATABASE_NAME)

    schemas = bucket.schemas()
    for s in schemas:
        print(s)