Skip to main content

Python client SDK for the H2O Connector Service — create connectors, open connections, and stream extracted data

Project description

h2o-connector-service

Python client SDK for the H2O Connector Service. Provides a high-level API to create connectors, open connections, and stream extracted data from supported data sources (PostgreSQL, Snowflake, Hive, Delta Lake, Blob Storage, and more).

pip install h2o-connector-service

Quick Start (H2O Cloud Discovery)

The recommended way to connect when running on H2O AI Cloud:

from h2o_connector_service import ConnectorService

with ConnectorService.from_discovery("https://cloud.h2o.ai", "my-workspace") as svc:
    with svc.open_session("CONNECTOR_TYPE_POSTGRESQL", {
        "host": "db.example.com",
        "port": "5432",
        "database": "mydb",
        "username": "user",
        "password": "pass",
    }) as session:
        # Stream rows one-by-one (constant memory)
        for row in session.stream_records():
            print(row)

Quick Start (Manual / Legacy)

For direct connections without H2O Cloud Discovery (deprecated):

from h2o_connector_service import ConnectorService

with ConnectorService("http://localhost:8080", "<your-oidc-token>", "my-workspace") as svc:
    with svc.open_session("CONNECTOR_TYPE_POSTGRESQL", {
        "host": "db.example.com",
        "port": "5432",
        "database": "mydb",
        "username": "user",
        "password": "pass",
    }) as session:
        for row in session.stream_records():
            print(row)

Output Formats

Once you have a session, stream data into various formats:

# CSV file (memory-safe — rows written as they arrive)
session.stream_to_csv("output.csv")

# pandas DataFrame (requires: pip install h2o-connector-service[pandas])
df = session.stream_to_pandas()

# Parquet file (memory-safe, chunked row groups)
# requires: pip install h2o-connector-service[parquet]
session.stream_to_parquet("output.parquet")

# datatable Frame (memory-safe, chunked rbind)
# requires: pip install h2o-connector-service[datatable]
frame = session.stream_to_data_table()

# H2O Frame (requires running H2O cluster + h2o.init())
# requires: pip install h2o-connector-service[h2o]
h2o_frame = session.stream_to_h2o_frame()

# Collect all rows into a list of dicts
records = session.stream_to_records()

Advanced Usage

For full control over the connector lifecycle, use the individual service clients:

from h2o_connector_service import (
    Client,
    ConnectorServiceClient,
    ConnectionServiceClient,
    ConnectorSession,
)

with Client.from_discovery("https://cloud.h2o.ai", "my-workspace") as client:
    connector_svc = ConnectorServiceClient(client)
    conn_svc = ConnectionServiceClient(client)

    # 1. Create a connector
    connector_svc.create_connector("my-workspace", {
        "metadata": {"name": "my-pg", "workspace_id": "my-workspace"},
        "spec": {
            "connector_type": "CONNECTOR_TYPE_POSTGRESQL",
            "config": {"host": "db.example.com", "port": "5432", "database": "mydb"},
        },
    })

    # 2. Create a connection
    connection = conn_svc.create_connection("my-workspace", {
        "metadata": {"workspace_id": "my-workspace"},
        "spec": {"connector_name": "workspaces/my-workspace/connectors/my-pg"},
    })

    # 3. Wait for the worker pod and stream data
    session = ConnectorSession(client, "my-workspace", connection["connection_id"])
    session.wait_for_worker_ready(timeout=300)
    session.stream_to_csv("output.csv")

Optional Dependencies

Install extras for additional output format support:

pip install h2o-connector-service[pandas]      # pandas DataFrames
pip install h2o-connector-service[parquet]      # Parquet files (pyarrow)
pip install h2o-connector-service[datatable]    # datatable Frames
pip install h2o-connector-service[h2o]          # H2O Frames (pandas + pyarrow + h2o)

Supported Connector Types

Connector Type Worker
CONNECTOR_TYPE_POSTGRESQL worker-postgresql (Java/JDBC)
CONNECTOR_TYPE_SNOWFLAKE worker-snowflake (Go)
CONNECTOR_TYPE_HIVE worker-hive (Java/JDBC)
CONNECTOR_TYPE_DELTA_LAKE worker-delta (Rust)
CONNECTOR_TYPE_S3 worker-blob (Go)
CONNECTOR_TYPE_AZURE_BLOB worker-blob (Go)
CONNECTOR_TYPE_GCS worker-blob (Go)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h2o_connector_service-0.1.0.dev8001.tar.gz (64.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

h2o_connector_service-0.1.0.dev8001-py3-none-any.whl (93.3 kB view details)

Uploaded Python 3

File details

Details for the file h2o_connector_service-0.1.0.dev8001.tar.gz.

File metadata

File hashes

Hashes for h2o_connector_service-0.1.0.dev8001.tar.gz
Algorithm Hash digest
SHA256 15ef849ef2788f3b463164bad383e4c0f927d2daf0bfaed6ce9278442952c59e
MD5 32a194de367f0b7569b3106778e5cfdd
BLAKE2b-256 8e7cb8ebcf76bd3c343921f7cec970c3266036f29f54dad9d749be61dafd97e6

See more details on using hashes here.

File details

Details for the file h2o_connector_service-0.1.0.dev8001-py3-none-any.whl.

File metadata

File hashes

Hashes for h2o_connector_service-0.1.0.dev8001-py3-none-any.whl
Algorithm Hash digest
SHA256 b04e69afd65485156b9ea2c27aab6e0481dbba7aae5da1e975f5b25a6764bb49
MD5 3547c92b7d4e9ad42208d8babea1b408
BLAKE2b-256 4b55935db7ee787d05b41289d0b124390da18550a1e6c47b4c452594eea56bf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page