Nelson
Nelson

Reputation: 117

Import CSV file from Local to Google Cloud SQL

Following the documentation, I am trying to import a local CSV onto a MySQL db hosted on GCP. I am using the following console command:

LOAD DATA LOCAL INFILE "C:/Users/user1/gcp/Feb_Pull.csv" INTO TABLE actuals CHARACTER SET 'utf8mb4' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"';

I get a 'File not found' error. Notes:

> LOAD DATA LOCAL INFILE
> "gs://[projectname].appspot.com/bucket/Feb_Pull.csv" INTO TABLE
> actuals CHARACTER SET 'utf8mb4' FIELDS TERMINATED BY ',' OPTIONALLY
> ENCLOSED BY '\"' ESCAPED BY '\"';

What am I doing incorrectly? Any guidance or example is appreciated - thanks!

Edit:

Upvotes: 0

Views: 2387

Answers (2)

Nelson
Nelson

Reputation: 117

When running the Google Cloud Console, local files can be accessed thru the "Launch Code Editor" in the top right. There you will see a file explorer to which you can upload files.

This will be your "local" directory from where the LOAD DATA LOCAL INFILE pulls from.

Upvotes: 1

Caner
Caner

Reputation: 59318

In windows the folder seperator is \ so correct format should be

LOAD DATA LOCAL INFILE "C:\\Users\\user1\gcp\\Feb_Pull.csv" ...

Upvotes: 1

Related Questions