Firebolt Python SDK

1.18.5 · active · verified Thu Apr 16

The Firebolt Python SDK provides a Python Database API Specification (DB-API 2.0) compliant interface for connecting and interacting with Firebolt, a cloud data warehouse. It enables executing SQL queries, managing connections, and fetching results programmatically. The current version is 1.18.5, with frequent patch releases addressing bug fixes and minor improvements, and occasional minor version bumps for new features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish a connection to Firebolt using service account credentials (client ID/secret) and execute a simple query. It relies on environment variables for sensitive information, which is a recommended practice. The DB-API 2.0 compliant `Connection` and `Cursor` objects are used to interact with the database.

import os
from firebolt.db import Connection
from firebolt.db.exceptions import OperationalError

# Ensure these environment variables are set:
# FIREBOLT_CLIENT_ID, FIREBOLT_CLIENT_SECRET, FIREBOLT_ACCOUNT_NAME
# FIREBOLT_DATABASE, FIREBOLT_ENGINE_NAME

try:
    connection = Connection(
        database=os.environ.get("FIREBOLT_DATABASE"),
        engine_name=os.environ.get("FIREBOLT_ENGINE_NAME"),
        client_id=os.environ.get("FIREBOLT_CLIENT_ID"),
        client_secret=os.environ.get("FIREBOLT_CLIENT_SECRET"),
        account_name=os.environ.get("FIREBOLT_ACCOUNT_NAME")
    )

    with connection.cursor() as cursor:
        cursor.execute("SELECT 1 as one, 'hello' as greeting")
        result = cursor.fetchone()
        print(f"Query result: {result}")

        cursor.execute("SHOW ENGINES")
        engines = cursor.fetchall()
        print(f"First 3 engines: {engines[:3]}")

except OperationalError as e:
    print(f"Firebolt Operational Error: {e}")
    print("Please ensure your credentials, database, and engine are correct.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →