[英]\copy statement in PostgreSQL using R
I want to execute the following statement on postgresql sending it from R: 我想在从R发送的postgresql上执行以下语句:
tname = 'foo'
con = some_connection_to_postgresql
q = paste("\\COPY", tname, "FROM 'foo.csv';")
dbGetQuery(con, q)
However, when I execute it, I get the following error: 但是,当我执行它时,出现以下错误:
Error: <SQL> '\COPY foo FROM 'foo.csv''
nanodbc/nanodbc.cpp:1587: 42601: ERROR: syntax error at or near "\";
Error while executing the query
However, the same script written from the terminal works perfectly fine. 但是,从终端编写的相同脚本可以很好地工作。
\\copy
is not a postgresql statement. \\copy
不是postgresql语句。 the psql
CLI converts \\copy
... from filename
into copy
... from stdin;
psql
CLI将\\copy
... from filename
转换为copy
... from stdin;
and then pipes the file's contents over the postgres connection. 然后通过postgres连接通过管道传输文件内容。
you'll have to do the same if you want to use copy. 如果要使用复制,则必须执行相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.