I am using PostgreSQL 11 COPY command to import large CSVs into the DB with Python, like the following:
COPY "ns"."table" ("col1", "col2") FROM STDIN WITH CSV HEADER DELIMITER AS ','
I didn't find any recent information if this operation is secure in terms of SQL injection attacks or should I manually go over the CSV and escape every value in the file (which is a very heavy operation).
Thanks!
curs.copy_expert(sql='COPY ...', file=file_obj)(psycopg2cursor)\n\\.\n, into file_obj they can get all data after that to be ignored. But they can't get arbitrary commands to run.