Import CSV file from Google Cloud Storage to Googl

2019-02-07 11:48发布

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)

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

2条回答
地球回转人心会变
2楼-- · 2019-02-07 12:33

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:

  1. Transform your file to CSV and do an import through UI
  2. Download your gs:// file to your local disk and then run LOAD DATA LOCAL INFILE pointing to the path on your local disk.
查看更多
三岁会撩人
3楼-- · 2019-02-07 12:33

Unsupported MySQL statements: Sending any of the following types of SQL statements will generate an error with the message "Error 1290: The MySQL server is running with the google option so it cannot execute this statement"

LOAD DATA INFILE Note: LOAD DATA LOCAL INFILE is supported. SELECT ... INTO OUTFILE SELECT ... INTO DUMPFILE INSTALL PLUGIN ... UNINSTALL PLUGIN CREATE FUNCTION ... SONAME ...

https://cloud.google.com/sql/faq#supportmysqlfeatures

Additionally, the mysql command line will not understand a gs:// file reference.

查看更多
登录 后发表回答