将CSV文件从Google云端存储导入Google Cloud SQL [英] Import CSV file from Google Cloud Storage to Google Cloud SQL
问题描述
我正在尝试使用以下命令将csv文件直接导入Google Cloud SQL。
I am trying to import a csv file directly into Google Cloud SQL using the command below.
LOAD DATA LOCAL INFILE "gs:/zuds/stg/ems/product_offering_fact/000002_0" INTO TABLE buydoc CHARACTER SET "utf8" FIELDS TERMINATED BY "^";
由于某种原因,它返回如下错误。我已确认该文件存在。但是,请注意错误字符串中的路径只有一个'/'
这是一个错误还是我错过了一些明显的东西?
For some reason, it is returning an error like below. I have confirmed that the file exists. However, notice that the path in the error string has only one '/' Is this a bug or am I missing something obvious?
ERROR 2 (HY000) at line 1: File 'gs:/zuds/stg/ems/product_offering_fact/000002_0' not found (Errcode: 2)
注意:如果我使用下面链接中描述的UI,它可以正常工作。但是,UI不支持非逗号分隔文件。
https://cloud.google.com/sql/docs/import-export
Note:If I use the UI described in the link below, it works. However, the UI does not support non-comma delimited files. https://cloud.google.com/sql/docs/import-export
推荐答案
Cloud SQL不支持使用gs://路径运行LOAD DATA LOCAL INFILE。在UI中,正如文档建议的那样,此时仅支持以逗号分隔的文件。以下是两种解决方法:
Cloud SQL doesn't support running LOAD DATA LOCAL INFILE with "gs://" path. From the UI, as the doc suggests, only comma delimited files are supported at this point. Here are two workarounds:
- 将文件转换为CSV并通过UI进行导入
- 下载将gs://文件发送到本地磁盘,然后运行LOAD DATA LOCAL INFILE指向本地磁盘上的路径。
这篇关于将CSV文件从Google云端存储导入Google Cloud SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!