ClickZetta SQLAlchemy Adapter

clickzetta-sqlalchemy is a dialect adapter for ClickZetta Lakehouse provided for SQLAlchemy, allowing code or upper-layer applications written with the SQLAlchemy interface to easily interact with ClickZetta Lakehouse.

Installation

Install clickzetta-sqlalchemy via pip:

pip install clickzetta-sqlalchemy

Quick Start

Execute SQL Query

from sqlalchemy import create_engine
from sqlalchemy import text

# Create an instance of the SQLAlchemy engine for ClickZetta Lakehouse
engine = create_engine(
    "clickzetta://username:password@instance.api.singdata.com/workspace?schema=schema&vcluster=default"
)

# Execute SQL query
sql = text("SELECT * FROM ecommerce_events_multicategorystore_live;")

# Execute the query using the engine
with engine.connect() as conn:
    result = conn.execute(sql)
    for row in result:
        print(row)

Example: Using PyGWalker for Visual Analysis of Lakehouse Data

PyGWalker is a tool that can convert pandas and polars data frames into a Tableau-style user interface for data visualization exploration. It simplifies the Jupyter Notebook data analysis and data visualization workflow, requiring only one line of code to implement.

from sqlalchemy import create_engine
from sqlalchemy import text
import pandas as pd
import pygwalker as pyg

# Create an instance of the SQLAlchemy engine for ClickZetta Lakehouse
engine = create_engine(
    "clickzetta://username:password@instance.api.singdata.com/workspace?schema=schema&vcluster=default"
)

# Execute SQL query
sql = text("SELECT * FROM ecommerce_events_multicategorystore_live;")

# Execute the query using the engine and get the results
with engine.connect() as conn:
    result = conn.execute(sql)
    df = pd.DataFrame(result.fetchall(), columns=result.keys())

# Use PyGWalker for visual analysis of the DataFrame
walker = pyg.walk(df)