# Unable run \\copy command via PGconn.( exec || query )

**URL:** <https://www.ruby-forum.com/t/unable-run-copy-command-via-pgconn-exec-query/164644>\
**Category:** Ruby\
**Created:** [April 3, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/unable-run-copy-command-via-pgconn-exec-query/164644 "2009-04-03T17:10:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashikalim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@ashikalim](https://www.ruby-forum.com/u/ashikalim)\
**Post date:** [April 3, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/unable-run-copy-command-via-pgconn-exec-query/164644/1 "2009-04-03T17:10:00Z")

</div>

Hi ,  
I am facing problem while executing following code :

require ‘postgres’  
obj = PGconn.new( ‘192.168.1.156’,5432 ,’’,’’,‘tikono’,‘tikono’,‘tikono’  
)  
a = “\COPY  
ivr\_interface.call\_flow(ref\_id,loaded\_time,menuid,expected\_dtmf,expected\_dtmf\_status,processing\_input,confirmation,external\_staus,external\_value)  
from ./backupFiles/ivr\_interface.call\_flow.new WITH DELIMITER ‘$’ NULL  
‘nil’”  
p a  
obj.exec( a )  
p obj.methods

Error :  
query.rb:5:in `exec’: ERROR: syntax error at or near “” at character 1  
(PGError)  
from query.rb:5  
X=============================X

If I use “\copy …” , Instead of “\copy” then I got  
query.rb:3: Invalid escape character syntax  
a = “\COPY  
ivr\_interface.call\_flow(ref\_id,loaded\_time,menuid,expected\_dtmf,expected\_dtmf\_status,processing\_input,confirmation,external\_staus,external\_value)  
from ./backupFiles/ivr\_interface.call\_flow.new WITH DELIMITER ‘$’ NULL  
‘nil’”

Note : Not PGERROR

If I use ,  
‘\COPY  
ivr\_interface.call\_flow(ref\_id,loaded\_time,menuid,expected\_dtmf,expected\_dtmf\_status,processing\_input,confirmation,external\_staus,external\_value)  
from ./backupFiles/ivr\_interface.call\_flow.new WITH DELIMITER ‘$’  
NULL ‘nil’’

I got the Error as ,  
query.rb:5:in `exec’: ERROR: syntax error at or near “” at character 1  
(PGError)  
from query.rb:5

Can anyone tell me How to escape this \copy in PGconn.( query|| exec )  
method ?
