I'm trying to import into postgres a csv
file containing the data for a table. One of the column of the table has jsonb
type.
One line of my csv
file contains something like
1,{"a":"b"}
Suppose the table has a schema
id | smallint |
data | jsonb |
If I try just to insert the data, everything works fine
INSERT INTO table VALUES (1, '{"a":"b"}');
Trying to import directly from the file with
COPY table FROM '/path/to/file.csv' DELIMITER ',' csv;
gives me the following error:
ERROR: invalid input syntax for type json
DETAIL: Token "a" is invalid.
CONTEXT: JSON data, line 1: {a...
COPY availability, line 1, column services: "{a: b}"
I tried to quote the fields with '
, with "
, with \"
and \'
, but nothing works..
Which is the correct syntax do do it?