This project is archived and is in readonly mode.
from ASCII-8BIT to UTF-8 error with MySQL seed from CSV file
-
Rohit Arondekar
- Tag changed from rails3, ruby-1.9.2, utf8 to mysql, rails3, ruby-1.9.2, utf8
- State changed from new to open
- Importance changed from to Low
If you can add unicode data into the Database via the MySQL console then I think this is a problem with the mysql gem and not Rails. Can you try opening a similar issue here http://rubyforge.org/tracker/?group_id=4550 ?
In the mean time can somebody confirm if this is indeed a Rails issue or not?
-
humancopy
I can confirm that without rails it works. :)
For example, this works fine:require 'mysql' c = Mysql.init # host, username, password, database c.connect(nil, "example", "example", "example") insert_new_country = c.prepare "INSERT INTO `countries` (name, code2, code3) VALUES (?, ? ,?)" open('countries.csv', 'r:UTF-8') do |countries| countries.read.each_line do |country| code2, code3, name = country.chomp.split("|") insert_new_country.execute name, code2, code3 end end c.close -
José Valim
Your example works fine outside Rails because your code is not iterating with any other IO or String. This is a bug in MySQL gem which is not marking the encoding of the strings.
-
Rohit Arondekar
- Assigned user set to Yehuda Katz (wycats)
-
Santiago Pastorino
- Tag changed from mysql, rails3, ruby-1.9.2, utf8 to mysql, rails3, ruby-192, utf8
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
