Skip to main content

snippets_py

Integration

New integration from credential
clickhouse = yepcode.integration.clickhouse('credential-slug')
New integration from plain authentication data
import clickhouse_connect

clickhouse = clickhouse_connect.get_client(
host='https://play-api.clickhouse.com',
port=8123,
username='playground',
password='clickhouse',
database='my_database_name'
)

Execute Query

Execute query
result_set = clickhouse.query(query='SELECT * FROM my_table FORMAT JSONEachRow')
dataset = result_set.result_rows
print(dataset)
Execute query (stream)
with clickhouse.query_row_block_stream('SELECT * FROM my_table FORMAT JSONEachRow') as stream:
for block in stream:
for row in block:
print(row)

Insert

Insert
data = [
[42, 'foo'],
[43, 'bar'],
]

clickouse.insert('my_table', data)