No project description provided
Project description
pych-client
pych-client is a ClickHouse client for Python. It targets the HTTP interface and offers the following features:
- Sync (
ClickHouseClient
) and async (AsyncClickHouseClient
) clients. - Streaming requests and responses.
- Optionally load credentials from environment variables, or from a configuration file.
Installation
# Default Python JSON parser:
pip install pych-client
# Faster orjson parser:
pip install pych-client[orjson]
Usage
from pych_client import ClickHouseClient
params = {"table": "test_pych"}
with ClickHouseClient() as client:
client.text('''
CREATE TABLE {table:Identifier} (a Int64, b Int64)
ENGINE MergeTree() ORDER BY (a, b)
''', params)
client.text("INSERT INTO {table:Identifier} VALUES", params, "(1, 2), (3, 4)")
client.text("INSERT INTO {table:Identifier} VALUES", params, [b"(5, 6)", b"(7, 8)"])
client.json("SELECT * FROM {table:Identifier} ORDER BY a", params)
# [{'a': '1', 'b': '2'}, {'a': '3', 'b': '4'}, {'a': '5', 'b': '6'}, {'a': '7', 'b': '8'}]
Command-line interface
pipx install pych-client
pych-client --help
Credential provider chain
The client looks for credentials in a way similar to the AWS SDK:
- If one of
base_url
,database
,username
orpassword
is specified, these values will be used. - If none of the previous values are specified, and one of
PYCH_BASE_URL
,PYCH_DATABASE
,PYCH_USERNAME
orPYCH_PASSWORD
environment variables are present, these values will be used. - If none of the previous values are specified, and the file
~/.config/pych-client/credentials.json
exists, the fieldsbase_url
,database
andusername
andpassword
will be used. - If none of the previous values are specified, the values
http://localhost:8213
,default
anddefault
will be used.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pych-client-0.2.5.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for pych_client-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dc05fb270048a4e96a1d141ea8da18f3b3426b99373174e91313b8eba466646 |
|
MD5 | 3bbe075b32eef7eb1907d67b213ae760 |
|
BLAKE2b-256 | 6470355132b16a3dfa07a1a0e63e3ef56a07959023a0232eec52dc213862382a |