copy command with psycopg2 library

前端 未结 3 1627
深忆病人
深忆病人 2021-01-04 11:21

Is it possible to run the command below through psycopg2? If so, how can I do it?

COPY table_name(col1,col2) FROM \'path/to/file.csv\' WITH HEADER DELIMITER          


        
3条回答
  •  醉话见心
    2021-01-04 11:53

    A Google search for psycopg2 copy finds, as the first hit for me, the psycopg manual, which includes instructions on using client-side COPY.

    If you want server-side COPY you just run the statement like any other SQL.

    As written above the command doesn't make any sense. I presume you meant to write a COPY ... TO or COPY ... FROM command and mangled it while hiding the real file name, etc.

提交回复
热议问题