Skip to main content

An OpenAPI client for the DeltaStream API

Project description

deltastream-connector

A Python client library for DeltaStream - a SQL streaming processing engine based on Apache Flink.

Features

  • Asynchronous API client for DeltaStream
  • Support for SQL statements execution
  • Streaming result sets
  • File attachments for SQL queries (e.g., JAR files for UDFs)
  • API Token authentication
  • Python 3.11+ support

Installation

pip install deltastream-connector

Quick Start

import asyncio
from deltastream.api.conn import APIConnection

# Initialize connection with API token
auth_token = os.getenv("DELTASTREAM_AUTH_TOKEN")

if not auth_token:
    raise ValueError("Environment variable 'DELTASTREAM_AUTH_TOKEN' is not set")

# Use the token to construct the DSN and create the connection
dsn = f"https://:{auth_token}@api.deltastream.io/v2"
conn = APIConnection.from_dsn(dsn)

async def main():
    # Execute SQL queries
    rows = await conn.query("SELECT 1;")
    
    # Process results asynchronously
    async for row in rows:
        print(row)

if __name__ == '__main__':
    asyncio.run(main())

File Attachments

The connector provides convenient helper functions to attach files (like JAR files for UDFs) to SQL queries without manually creating blob objects.

Simple File Attachment

import asyncio
from deltastream.api.conn import APIConnection

async def main():
    conn = APIConnection.from_dsn("https://:{token}@api.deltastream.io/v2")
    
    # Create a function source with a JAR file attachment
    await conn.exec_with_files(
        "CREATE FUNCTION_SOURCE \"my_udf\" WITH ('file' = 'my_function.jar', 'description' = 'My custom UDF');",
        ["/path/to/my_function.jar"]
    )
    
    # Query function sources and get results
    rows = await conn.query_with_files("SHOW FUNCTION_SOURCES;")
    async for row in rows:
        print(f"Function: {row[0]}, Status: {row[1]}")

if __name__ == '__main__':
    asyncio.run(main())

Advanced File Attachment Configuration

# Custom file names and content types
await conn.exec_with_files(
    "CREATE FUNCTION_SOURCE \"advanced_udf\" WITH ('file' = 'custom_name.jar');",
    [{
        "path": "/path/to/actual_file.jar",
        "name": "custom_name.jar",
        "content_type": "application/java-archive"
    }]
)

# Multiple files
await conn.exec_with_files(
    "CREATE FUNCTION_SOURCE \"multi_file_udf\" WITH ('file' = 'main.jar', 'lib' = 'dependency.jar');",
    [
        "/path/to/main.jar",
        {"path": "/path/to/lib.jar", "name": "dependency.jar"}
    ]
)

Authentication

The connector uses API token authentication. You can obtain an API token from the DeltaStream platform by running CREATE API_TOKEN api_token_name; using the console.

Support

For support, please contact support@deltastream.com or open an issue on our GitHub repository.

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

deltastream_connector-0.3.0.tar.gz (66.2 kB view details)

Uploaded Source

Built Distribution

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

deltastream_connector-0.3.0-py3-none-any.whl (113.9 kB view details)

Uploaded Python 3

File details

Details for the file deltastream_connector-0.3.0.tar.gz.

File metadata

  • Download URL: deltastream_connector-0.3.0.tar.gz
  • Upload date:
  • Size: 66.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for deltastream_connector-0.3.0.tar.gz
Algorithm Hash digest
SHA256 32d8e71bd0be01dc766abb102c8e63a52e0c4f635512942fd96b086be1bb7409
MD5 c2cdd1614e603cc70fb3c7dc8de5a460
BLAKE2b-256 b399a069aefa8a636f2d5517c18adcaae6275d63f9103e9e16be103ce12bcfc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for deltastream_connector-0.3.0.tar.gz:

Publisher: release.yml on deltastreaminc/deltastream-connector-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deltastream_connector-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deltastream_connector-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef97ac0e6a2d464914d842b26a3befd44c368a63f1db8decf82e5d37308bc6eb
MD5 f0a9f43aa7d452ad985be4a688c863cd
BLAKE2b-256 bc380020d60e2e279a024e9f1e1e2f5dcefccb4206c0f0a48df26ff695d22cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for deltastream_connector-0.3.0-py3-none-any.whl:

Publisher: release.yml on deltastreaminc/deltastream-connector-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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