除非我退出脚本,否则谷歌云操作一直处于RUNNING



我正试图将csv数据从谷歌存储导入谷歌云sql表,除非我退出脚本,否则操作状态将停留在RUNNING

credentials_dict = {...}  # service account json
credentials = service_account.Credentials.from_service_account_info(
credentials_dict, scopes=['https://www.googleapis.com/auth/cloud-platform']
)
authed_session = AuthorizedSession(credentials)
payload={
"importContext":
{
"fileType": "CSV",
"uri": "gs://<path-to-csv>",
"database": "<db-name>",
"csvImportOptions":
{
"table": "<table-name>"
}
}
}
response = authed_session.request('POST', 
'https://www.googleapis.com/sql/v1beta4/projects/<project-id>/instances/<cloude-sql-instance-id>/import',json=payload)
data = json.loads(response.text)
name = data["name"]
while response.status_code == 200 and  data["status"] != "DONE":
sleep(5)
response = authed_session.request(
'GET', 'https://www.googleapis.com/sql/v1beta4/projects/<project-id>/operations/' + name)
data = json.loads(response.text)

从诊断云SQL实例的问题开始解决这一问题是一个很好的方法。

我将从查看云SQL实例操作日志开始

相关内容

  • 没有找到相关文章

最新更新