Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用请求通过http协议将设置发送到clickhouse_Python_Python Requests_Clickhouse - Fatal编程技术网

Python 使用请求通过http协议将设置发送到clickhouse

Python 使用请求通过http协议将设置发送到clickhouse,python,python-requests,clickhouse,Python,Python Requests,Clickhouse,通过clickhouse客户端代码如下所示: clickhouse-client --input_format_allow_errors_num=1 --input_format_allow_errors_ratio=0.1 --query="INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV" query = 'INSERT INTO db.table VALUES (..., ...., ...) FORMAT

通过
clickhouse客户端
代码如下所示:

clickhouse-client --input_format_allow_errors_num=1
--input_format_allow_errors_ratio=0.1
--query="INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV"
query = 'INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV'
r = requests.post(host, data=query, auth=(CH_USER, CH_PASSWORD), verify=True)
我正在使用
请求
,我的代码如下所示:

clickhouse-client --input_format_allow_errors_num=1
--input_format_allow_errors_ratio=0.1
--query="INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV"
query = 'INSERT INTO db.table VALUES (..., ...., ...) FORMAT CSV'
r = requests.post(host, data=query, auth=(CH_USER, CH_PASSWORD), verify=True)
如何传递设置,例如

--input_format_allow_errors_num=1
--input_format_allow_errors_ratio=0.1

使用
python请求

看起来您可以将这些设置作为查询参数传递,并将SQL查询传递到POST-response主体中,尽管您似乎还可以将其包含在查询参数中

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)

试试看。我从以下方面了解到所有这些:

考虑使用专用软件包。参见示例:@vladimir我正在使用logs api yandex库,它在引擎盖下使用
请求