# 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` and `timezone` are the optional parameters.
```python
from peaka.client import connect_to_peaka
conn = connect_to_peaka(api_key="<YOUR_API_KEY>", catalog="<CATALOG_NAME>", schema="<SCHEMA_NAME>", timezone="<TIMEZONE>")
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://peaka.com/docs/python-client",
"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/58/2d/2823ff6140d3beacd533afe6f1cb9fdd8c014ce1d596836846e34522b9bc/peaka-1.0.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` and `timezone` are the optional parameters.\n\n```python\nfrom peaka.client import connect_to_peaka\n\nconn = connect_to_peaka(api_key=\"<YOUR_API_KEY>\", catalog=\"<CATALOG_NAME>\", schema=\"<SCHEMA_NAME>\", timezone=\"<TIMEZONE>\")\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.0.0",
"project_urls": {
"Homepage": "https://peaka.com/docs/python-client"
},
"split_keywords": [
"data",
" peaka"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5519b052c427b430020ef25d13f595bb9a9d8e87e77c1a9fcbb1d9b6da525a02",
"md5": "076fc54a141825e9f7a2d1162a34fcdf",
"sha256": "5eb5c16d9472a284b06f85163ac0868e454d3bf2b5efbb1efbc514e85d5b3637"
},
"downloads": -1,
"filename": "peaka-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "076fc54a141825e9f7a2d1162a34fcdf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8175,
"upload_time": "2024-04-16T14:29:28",
"upload_time_iso_8601": "2024-04-16T14:29:28.687507Z",
"url": "https://files.pythonhosted.org/packages/55/19/b052c427b430020ef25d13f595bb9a9d8e87e77c1a9fcbb1d9b6da525a02/peaka-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "582d2823ff6140d3beacd533afe6f1cb9fdd8c014ce1d596836846e34522b9bc",
"md5": "521d32b70ac7805502184088895ec943",
"sha256": "04c0f6e21e54d14d91e3018e1f670db4a7563e9cf292e5e8a37a01afd1f22336"
},
"downloads": -1,
"filename": "peaka-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "521d32b70ac7805502184088895ec943",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8695,
"upload_time": "2024-04-16T14:29:32",
"upload_time_iso_8601": "2024-04-16T14:29:32.338867Z",
"url": "https://files.pythonhosted.org/packages/58/2d/2823ff6140d3beacd533afe6f1cb9fdd8c014ce1d596836846e34522b9bc/peaka-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-16 14:29:32",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "peaka"
}