Skip to main content

A Python client for Peaka

Project description

Peaka Python client

Client for Peaka, a Zero-ETL data integration platform. Provides a low-level client and a DBAPI 2.0 implementation and a SQLAlchemy adapter. It supports Python>=3.8 and PyPy.

Usage

The Python Database API (DBAPI)

Installation

$ pip install peaka

Quick Start

Use the DBAPI interface to query Peaka:

You can call the connect_to_peaka method with your Peaka api_key. catalog, schema, timezone and zone are the optional parameters.

from peaka.dbapi import connect_to_peaka

conn = connect_to_peaka(api_key="<YOUR_API_KEY>", catalog="<CATALOG_NAME>", schema="<SCHEMA_NAME>", timezone="<TIMEZONE>", zone="<'eu' | 'us'>")
    
cur = conn.cursor()
cur.execute("SELECT * FROM <table_name>")
rows = cur.fetchall()

You can query your table directly, if you enter the catalog and schema when you connect.

SQLAlchemy

Installation

$ pip install peaka[sqlalchemy]

Usage

To connect to Peaka using SQLAlchemy, use a connection string (URL) following this pattern:

peaka://dbc.peaka.studio:4567/<catalog>/<schema>?http_scheme=https&extra_credential=[["peakaKey",<YOUR_API_KEY>]]&access_token=true

NOTE: schema is optional

Examples:

from sqlalchemy import create_engine
from sqlalchemy.schema import Table, MetaData
from sqlalchemy.sql.expression import select, text

engine = create_engine('peaka://dbc.peaka.studio:4567/<CATALOG_NAME>/<SCHEMA_NAME>?http_scheme=https&extra_credential=[["peakaKey",<YOUR_API_KEY>]]&access_token=true')
connection = engine.connect()

rows = connection.execute(text("SELECT * FROM <TABLE_NAME>")).fetchall()

# or using SQLAlchemy schema
nodes = Table(
    '<TABLE_NAME>',
    MetaData(schema='<SCHEMA_NAME>'),
    peaka_autoload=True,
    autoload_with=engine
)
rows = connection.execute(select(nodes)).fetchall()

In order to pass additional connection attributes use connect_args method. Attributes can also be passed in the connection string.

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

peaka-1.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

peaka-1.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file peaka-1.1.0.tar.gz.

File metadata

  • Download URL: peaka-1.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for peaka-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e76e7b93a1a49ed0735ce82deac414777e6add54f1921ffb79178011ed24fea7
MD5 a16a5c970e7c488ab9af7dbfcec1f274
BLAKE2b-256 adc8c9f436c99db18c43641088f921a7dc93cd7982e9195058df3162a0b58d07

See more details on using hashes here.

File details

Details for the file peaka-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: peaka-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for peaka-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6db7f154a2293bb3c84044d819dd929ea353a381ceebfcb022c834c06c690f6f
MD5 a155cfee846fe3c2f6b21b3cc97c040e
BLAKE2b-256 e79c864a67c87962b7833c34335cd5b0e0dcdc1df7f931998b73ddda9ef79c2c

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