Rockset Python Client

2.1.2 · abandoned · verified Thu Apr 16

The Rockset Python client (`rockset`) provides an SDK for interacting with the Rockset API, a real-time analytics database. It enables users to create and manage resources, execute queries, and handle data. However, as of June 2024, Rockset's public services were shut down following its acquisition by OpenAI, with its technology integrated into OpenAI's infrastructure. Consequently, this client library is no longer functional for public use and is preserved for archival purposes.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the Rockset client using an API key from an environment variable and attempts to list workspaces and create an API key. Note that this code will not function as Rockset's public services have been shut down.

import os
from rockset import RocksetClient, Regions, ApiException

# Rockset services were shut down in June 2024. This code is for archival/demonstration only.
# Ensure ROCKSET_API_KEY is set in your environment variables if attempting to run against a hypothetical Rockset instance.
api_key = os.environ.get('ROCKSET_API_KEY', 'YOUR_ROCKSET_API_KEY')
if api_key == 'YOUR_ROCKSET_API_KEY':
    print("WARNING: ROCKSET_API_KEY environment variable not set. Using placeholder.")

try:
    # Initialize the Rockset client
    # The host parameter replaced 'api_server' in v1.0.0
    rs = RocksetClient(host=Regions.use1a1, api_key=api_key)

    # Example: List workspaces
    print("Attempting to list workspaces...")
    workspaces = rs.Workspaces.list_all()
    print(f"Found {len(workspaces)} workspaces:")
    for ws in workspaces:
        print(f"- {ws.name}")

    # Example: Create an API key (demonstration, real usage should handle existing keys)
    # This operation will likely fail as the service is offline.
    try:
        new_api_key_name = "my-test-api-key"
        print(f"\nAttempting to create API key: {new_api_key_name}...")
        created_key = rs.APIKeys.create(name=new_api_key_name, role="member")
        print(f"Successfully created API key: {created_key.name}")
    except ApiException as e:
        print(f"Could not create API key (expected due to service shutdown): {e}")

except ApiException as e:
    print(f"An API error occurred: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →