Gwenlake Python Library
The Gwenlake Python library provides convenient access to the Gwenlake API
from applications written in Python. A single Gwenlake client gives you access
to your catalog — projects, datasets, files and SQL.
Installation
pip install -U git+https://github.com/gwenlake/gwenlake-python
Authentication
The client authenticates with a Bearer token, resolved in this order:
- an explicit
api_key/credentialspassed to the client, - a named
profile, - the
GWENLAKE_API_KEYenvironment variable, - the
defaultprofile in~/.gwenlake/credentials.
export GWENLAKE_API_KEY='sk-...'
import gwenlake
# uses GWENLAKE_API_KEY, or the default ~/.gwenlake/credentials profile
client = gwenlake.Gwenlake()
# or pass the key explicitly
client = gwenlake.Gwenlake(api_key="sk-...")
# or pick a profile from ~/.gwenlake/credentials
client = gwenlake.Gwenlake(profile="myteam")
The ~/.gwenlake/credentials file is an INI file with one section per profile,
holding either a static token (API key) or OAuth2 client_id / client_secret.
Projects
projects = client.projects.list()
for p in projects:
print(p["alias"], p["id"])
project = client.projects.get("res.project.…")
Datasets
datasets = client.datasets.list()
for d in datasets:
print(d["alias"], d["id"])
dataset = client.datasets.get("res.dataset.…")
Files
Files live inside a dataset.
dataset_id = "res.dataset.…"
# list files
for f in client.files.list(dataset_id):
print(f["filename"], f["file_size"])
# upload a local file (optionally into a subdirectory with path=...)
client.files.upload(dataset_id, "report.pdf")
client.files.upload(dataset_id, "report.pdf", path="docs")
# download a file
content = client.files.download(dataset_id, "report.pdf")
# presigned URL / delete
url = client.files.presigned_url(dataset_id, "report.pdf")
client.files.delete(dataset_id, "report.pdf")
SQL
Run SQL against a dataset (DuckDB), referencing it as
'<project_alias>.<dataset_alias>'. With format="json" the rows are returned
under data:
result = client.statements.create(
statement="SELECT * FROM 'flights.flight-data' LIMIT 10",
format="json",
)
for row in result["data"]:
print(row)
Pass a connection_id to run the statement against a connection's native engine
(PostgreSQL, S3, …) instead of a dataset.
Async
Every resource is also available on AsyncGwenlake:
import asyncio
import gwenlake
async def main():
client = gwenlake.AsyncGwenlake()
print(await client.projects.list())
asyncio.run(main())
See examples/ for runnable scripts.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gwenlake-0.6.0.tar.gz.
File metadata
- Download URL: gwenlake-0.6.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5b1f4e7dd31db35de48df52cdc5426b2ad9ea57cc178621684f618231cf34db
|
|
| MD5 |
1b93d798ed240fbb909accf699ac586d
|
|
| BLAKE2b-256 |
eaca3adeb950b9486f996c55bef10968594bba5f308fdc88198f511c7267bd94
|
Provenance
The following attestation bundles were made for gwenlake-0.6.0.tar.gz:
Publisher:
python-publish.yml on gwenlake/gwenlake-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gwenlake-0.6.0.tar.gz -
Subject digest:
a5b1f4e7dd31db35de48df52cdc5426b2ad9ea57cc178621684f618231cf34db - Sigstore transparency entry: 1825936593
- Sigstore integration time:
-
Permalink:
gwenlake/gwenlake-python@99c549119ca5b6bc7d209c236f9a24139d65e0b2 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/gwenlake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@99c549119ca5b6bc7d209c236f9a24139d65e0b2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gwenlake-0.6.0-py3-none-any.whl.
File metadata
- Download URL: gwenlake-0.6.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7946c64719b720facd0f7ecdd88cea7129eff2e1d8a64662d861d39810edc8e
|
|
| MD5 |
b53290aa52dd1685d693ac247d1c9c5c
|
|
| BLAKE2b-256 |
d71ed21212d8769e2cb55d7685c108c018eabc01ebf69f9049aa6d9faadb82a0
|
Provenance
The following attestation bundles were made for gwenlake-0.6.0-py3-none-any.whl:
Publisher:
python-publish.yml on gwenlake/gwenlake-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gwenlake-0.6.0-py3-none-any.whl -
Subject digest:
f7946c64719b720facd0f7ecdd88cea7129eff2e1d8a64662d861d39810edc8e - Sigstore transparency entry: 1825936651
- Sigstore integration time:
-
Permalink:
gwenlake/gwenlake-python@99c549119ca5b6bc7d209c236f9a24139d65e0b2 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/gwenlake
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@99c549119ca5b6bc7d209c236f9a24139d65e0b2 -
Trigger Event:
release
-
Statement type: