◐ Shell
clean mode source ↗

cursor.copy_from() method doesn't work with quoted named tables

The error below is thrown when trying to copy a CSV file into a given Postgres table that have quotes in the name in order to use CamelCase style.

The Error message is:

pg.ProgrammingError: ERROR:  syntax error at or near "User"
LINE 1: copy "public."User"" from stdin (format csv,delimiter ','...

The code that generates the error:

cursor.copy_from(file, "public.\"User\"", null="") 

where file is the csv file object and the second argument is the schema.table name

Trying others names to the schema.table such as 'public."User"' or any variations doesn't work.

I assume the problem is not a Postgres internal problem because the code above works with psycopg2