我是CloudSQL的新手&我正在尝试插入40+不同列和超过150万行的记录。然而,我无法在谷歌CloudSQL中做到这一点。我已经采取了下面列出的相当多的措施来解决这个问题,但我得到的主要错误是:
ERROR:
textPayload: "2019-04-12T06:10:47.348295Z 8554 [Note] Aborted connection 8554 to db: 'xxxxx_xxx' user: 'root' host: 'x.x.x.x' (Got an error reading communication packets)" 摘要:
在CloudSQL.
PyMySql,部署时间非常长,当我检查我的表时,部署是的MySql错误日志显示上述内容。我尝试了以下操作:
API URL/ .txt / .json文件上载而不是现在使用.csv..txt默认配置导致限制,我添加了以下内容:- sql\_mode : MAXDB,NO\_AUTO\_CREATE\_USER
- max\_allowed\_packet: 1073741824
- net\_read\_timeout: 4294967295
- wait\_timeout: 31536000
def adddata():
try:
conn = pymysql.connect(unix_socket='/cloudsql/' + 'karto-235001:asia-east1:karto', user='xxx', password='xxx', db='xxx')
cur = conn.cursor()
insert_ = "INSERT INTO data_table(a, b, c) VALUES (%s, %s, %s)"
with open('info.csv', newline='') as myFile:
reader = csv.reader(myFile)
for item in reader:
cur.execute(insert_, (item[3], item[4], item[5]))
conn.commit()
cur.close()
finally:
conn.close()我已经在线查看并实现了CloudSQL和其他堆栈溢出用户推荐的解决方案。如果有人能找出我做错了什么,或者我的代码或配置是否有问题?非常感谢。
https://stackoverflow.com/questions/55664232
复制相似问题