【问题标题】:Python: Insert data with for loop without timeout errorPython:使用for循环插入数据而没有超时错误
【发布时间】:2023-04-05 03:34:01
【问题描述】:

我需要按年份批量插入数据,但我得到了

%Server% ping 错误:超时。连接已关闭, 重新连接。

而且我不知道每个插入会长多长时间。

我想我应该使用异步?

import pandas as pd
from clickhouse_driver import Client

client = Client(host, user=user, password=password, database = 'default')

dr = pd.date_range(start='1979-01-01', end='2029-01-31') # date ranges
for i in range(0,len(dr)):
    year  = dr[i].year
    query = f"insert into t2 select * from t1 where y = {year}"
    client.execute(query)

【问题讨论】:

    标签: python sql clickhouse


    【解决方案1】:

    send_receive_timeout

    client = Client(host, user=user, password=password, database = 'default', send_receive_timeout = 1000)
    

    https://github.com/mymarilyn/clickhouse-driver/issues/196

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-03
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-26
      • 2021-09-02
      • 1970-01-01
      相关资源
      最近更新 更多