# Peaka Python client
Client for [Peaka](https://peaka.com/), 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.
```python
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**:
```python
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](https://docs.sqlalchemy.org/en/14/core/engines.html#sqlalchemy.create_engine.params.connect_args) method.
Attributes can also be passed in the connection string.
Raw data
{
"_id": null,
"home_page": "https://docs.peaka.com/db-drivers/python",
"name": "peaka",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "data, peaka",
"author": "Peaka",
"author_email": "integrations@peaka.com",
"download_url": "https://files.pythonhosted.org/packages/ad/c8/c9f436c99db18c43641088f921a7dc93cd7982e9195058df3162a0b58d07/peaka-1.1.0.tar.gz",
"platform": null,
"description": "# Peaka Python client\n\nClient for [Peaka](https://peaka.com/), a Zero-ETL data integration platform. \nProvides a low-level client and a DBAPI 2.0 implementation and a SQLAlchemy adapter.\nIt supports Python>=3.8 and PyPy.\n\n## Usage\n\n### The Python Database API (DBAPI)\n\n**Installation**\n\n```\n$ pip install peaka\n```\n\n**Quick Start**\n\nUse the DBAPI interface to query Peaka:\n\nYou can call the `connect_to_peaka` method with your Peaka `api_key`. `catalog`, `schema`, `timezone` and `zone` are the optional parameters.\n\n```python\nfrom peaka.dbapi import connect_to_peaka\n\nconn = connect_to_peaka(api_key=\"<YOUR_API_KEY>\", catalog=\"<CATALOG_NAME>\", schema=\"<SCHEMA_NAME>\", timezone=\"<TIMEZONE>\", zone=\"<'eu' | 'us'>\")\n \ncur = conn.cursor()\ncur.execute(\"SELECT * FROM <table_name>\")\nrows = cur.fetchall()\n```\n\nYou can query your `table` directly, if you enter the `catalog` and `schema` when you connect.\n\n### SQLAlchemy\n\n**Installation**\n\n```\n$ pip install peaka[sqlalchemy]\n```\n\n**Usage**\n\nTo connect to Peaka using SQLAlchemy, use a connection string (URL) following this pattern:\n\n```\npeaka://dbc.peaka.studio:4567/<catalog>/<schema>?http_scheme=https&extra_credential=[[\"peakaKey\",<YOUR_API_KEY>]]&access_token=true\n```\n\nNOTE: `schema` is optional\n\n**Examples**:\n\n```python\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.schema import Table, MetaData\nfrom sqlalchemy.sql.expression import select, text\n\nengine = create_engine('peaka://dbc.peaka.studio:4567/<CATALOG_NAME>/<SCHEMA_NAME>?http_scheme=https&extra_credential=[[\"peakaKey\",<YOUR_API_KEY>]]&access_token=true')\nconnection = engine.connect()\n\nrows = connection.execute(text(\"SELECT * FROM <TABLE_NAME>\")).fetchall()\n\n# or using SQLAlchemy schema\nnodes = Table(\n '<TABLE_NAME>',\n MetaData(schema='<SCHEMA_NAME>'),\n peaka_autoload=True,\n autoload_with=engine\n)\nrows = connection.execute(select(nodes)).fetchall()\n```\n\nIn order to pass additional connection attributes use [connect_args](https://docs.sqlalchemy.org/en/14/core/engines.html#sqlalchemy.create_engine.params.connect_args) method.\nAttributes can also be passed in the connection string.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python client for Peaka",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://docs.peaka.com/db-drivers/python"
},
"split_keywords": [
"data",
" peaka"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e79c864a67c87962b7833c34335cd5b0e0dcdc1df7f931998b73ddda9ef79c2c",
"md5": "a155cfee846fe3c2f6b21b3cc97c040e",
"sha256": "6db7f154a2293bb3c84044d819dd929ea353a381ceebfcb022c834c06c690f6f"
},
"downloads": -1,
"filename": "peaka-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a155cfee846fe3c2f6b21b3cc97c040e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8254,
"upload_time": "2024-05-17T11:50:47",
"upload_time_iso_8601": "2024-05-17T11:50:47.640525Z",
"url": "https://files.pythonhosted.org/packages/e7/9c/864a67c87962b7833c34335cd5b0e0dcdc1df7f931998b73ddda9ef79c2c/peaka-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "adc8c9f436c99db18c43641088f921a7dc93cd7982e9195058df3162a0b58d07",
"md5": "a16a5c970e7c488ab9af7dbfcec1f274",
"sha256": "e76e7b93a1a49ed0735ce82deac414777e6add54f1921ffb79178011ed24fea7"
},
"downloads": -1,
"filename": "peaka-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "a16a5c970e7c488ab9af7dbfcec1f274",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8767,
"upload_time": "2024-05-17T11:50:48",
"upload_time_iso_8601": "2024-05-17T11:50:48.704512Z",
"url": "https://files.pythonhosted.org/packages/ad/c8/c9f436c99db18c43641088f921a7dc93cd7982e9195058df3162a0b58d07/peaka-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-17 11:50:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "peaka"
}