Via clickhouse-client
code looks like this:
clickhouse-client --input_format_allow_errors_num=1 --input_format_allow_errors_ratio=0.1 --query="INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV"
I am using requests
and my code looks like this:
query = 'INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV' r = requests.post(host, data=query, auth=(CH_USER, CH_PASSWORD), verify=True)
how to pass settings such as
--input_format_allow_errors_num=1 --input_format_allow_errors_ratio=0.1
using python-requests
?
Advertisement
Answer
It looks like you pass those settings as query parameters and the SQL query in the POST response body, though it seems like you can include that in query params as well.
import requests auth = ("username", "password") query = 'INSERT INTO db.table VALUES (..., ..., ...) FORMAT CSV' params = { "input_format_allow_errors_num": 1, "input_format_allow_errors_ratio": 0.1 } response = requests.post(host, data=query, params=params, auth=auth)
Give that a shot. I’m getting all this from: https://clickhouse.tech/docs/en/interfaces/http/