I am trying to connect a csv file to alloydb (postgres gcp managed database) and I'm getting the following error:
2024-03-04T19:21:15.008000Z LOG pgloader version "3.6.7~devel"
2024-03-04T19:21:15.012000Z LOG Parsing commands from file #P"/home/julie_wang/csv_to_postgres.load"
KABOOM!
ESRAP-PARSE-ERROR: At
WITH truncate,
^ (Line 5, Column 4, Position 191)
In context COMMANDS:
While parsing COMMANDS. Expected:
the character Tab
or the character Newline
or the character Return
or the character Space
or the string "--"
or the string "/*"
or the string "load"
An unhandled error condition has been signalled: At
This is my code.
LOAD CSV
FROM 'path/to/file.csv' ("Site Name", Year, Deaths, Multivitamin)
INTO postgresql://postgres:password@ipaddress/postgres ("Site Name", Year, Deaths, Multivitamin);
WITH truncate,
skip header = 1,
fields optionally enclosed by '"',
fields escaped by double-quote,
fields terminated by ','
SET client_encoding to 'latin1',
work_mem to '12MB',
standard_conforming_strings to 'on'
BEFORE LOAD DO
$$ drop table if exists csv; $$,
$$ create table csv (
"Site Name" text,
Year int,
Deaths int,
Multivitamin int
);
$$;
I'm not sure if the issue is due to how I'm calling the connection string to cloud sql or a syntax issue due to pgloader. I don't have a lot of experience with pgloader. If someone has any insights that would be great