首页 > 解决方案 > 将数据帧上传到 Google BigQuery 时一致(10054,WSAERROR)

问题描述

我在运行此代码时遇到问题。几周前它对一组约 160 个数据帧执行良好,但最近,Google BigQuery 在尝试运行代码时开始抛出 WSAERROR。

import glob
import pandas as pd
import os
import pandas_gbq as pd_gbq
import time
import tqdm
from google.cloud import bigquery, exceptions

for file in glob.glob(stage_folder)[:34]:
    df = pd.read_csv(file)
    pd_gbq.to_gbq(df, output_table, project_id = project_id, progress_bar= True, if_exists='append', chunksize = 330000)
    print('Sleeping...')
    time.sleep(300)

我试图调整块大小,但这只是延迟了 WSAERROR 的发生,并没有阻止它。我的研究表明这可能是标题的问题,但是如何更改 to_gbq 中的标题?

这是最新的 Traceback。如果需要,我可以提供完整的,Stack 只是将完整的回溯解释为垃圾邮件。

---------------------------------------------------------------------------
SysCallError                              Traceback (most recent call last)
~\OneDrive - The Home Depot\Documents\anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py in _send_until_done(self, data)
    316             try:
--> 317                 return self.connection.send(data)
    318             except OpenSSL.SSL.WantWriteError:

~\OneDrive - The Home Depot\Documents\anaconda3\lib\site-packages\OpenSSL\SSL.py in send(self, buf, flags)
   1736         result = _lib.SSL_write(self._ssl, buf, len(buf))
-> 1737         self._raise_ssl_error(self._ssl, result)
   1738         return result

~\OneDrive - The Home Depot\Documents\anaconda3\lib\site-packages\OpenSSL\SSL.py in _raise_ssl_error(self, ssl, result)
   1638                     if errno != 0:
-> 1639                         raise SysCallError(errno, errorcode.get(errno))
   1640                 raise SysCallError(-1, "Unexpected EOF")

SysCallError: (10054, 'WSAECONNRESET')

谢谢你的帮助!

标签: pythonpandasgoogle-bigquery

解决方案


推荐阅读