I have a Postgres database that I am populating with CSV files using COPY. Some tables have columns of type bytea, and in these CSV files it is specified the path to the binary file.
Given the table
CREATE TABLE mytable
( ID INTEGER,
File BYTEA
);
I know I can insert binary files with
INSERT INTO mytable VALUES (1, pg_read_binary_file('/path/to/file'));
but, can I specify to do so with COPY reading the /path/to/file from the CSV files? Can you apply functions to COPY in Postgres? I know in MySQL you can do it using something like
LOAD DATA
INFILE /path/to/csv
INTO TABLE mytable
( ID,
@File
)
SET File = LOAD_FILE(@File);
but I have to stick to Postgres and store the binary files in the database.