I'm trying to export a csv to the table in MySQL. *'db.copy_into(....)'* does
not seem to be working. Is there an alternate command to bulk load the csv
to the table without using the INSERT INTO or any line-by-line insert
statement?
On Monday, December 10, 2012 9:19:45 AM UTC-8, Jeremy Evans wrote:
>
> On Monday, December 10, 2012 5:06:55 AM UTC-8, Gastón Ramos wrote:
>>
>> Hi all, I'm trying to use \copy to import a csv file and I'm getting this
>> error:
>>
>> DB.run "\copy user (name, surname) from /home/gramos/download/my_file.csv
>> DELIMITER '|'"
>>
>> E, [2012-12-10T09:41:54.992473 #22222] ERROR -- : PG::Error: ERROR:
>> syntax error at or near "\"
>>
>> and when I try COPY from command
>>
>> DB.run "COPY user (name, surname) FROM
>> '/home/gramos/download/my_file.csv' DELIMITER '|'"
>>
>> E, [2012-12-10T09:45:44.456877 #22222] ERROR -- : PG::Error: ERROR: must
>> be superuser to COPY to or from a file
>> HINT: Anyone can COPY to stdout or from stdin. psql's \copy command also
>> works for anyone.:
>>
>> I'm using postgresql-9.1 and sequel 3.35.0
>>
>> any idea about this?
>>
>
> First, COPY with a filename specifies a filename on the server, not on the
> client, which is why you need to be a superuser to use it. I'm guessing
> the file you are trying to use is on the client, so you can't do that. If
> the file actually is on the server, that DB.run command should work if you
> are a superuser and the database system user has appropriate permissions to
> the file.
>
> Second, with Sequel you need to use DB.copy_into for COPY FROM STDIN.
> Maybe something like this:
>
> DB.copy_into(:user, :columns=>[:name, :surname],
> :data=>File.new("/home/gramos/download/my_file.csv", "rb"),
> :options=>"DELIMITER '|'")
>
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/XqtD5Kbx7ysJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.