[英]Ruby Mysql cannot insert special character
using ruby's mysql gem i'm inserting a new row into a table wich has encoding utf8_spanish_ci. 我使用ruby的mysql gem将新行插入编码为utf8_spanish_ci的表中。
here's the code i'm executing 这是我正在执行的代码
require 'mysql'
con = Mysql.new(#connecionparameters)
rs = con.query("INSERT INTO `qubi_horoscopo`.`signos` (`name`) VALUES ('acción')")
and when i query the table i get the following result : 当我查询表时,我得到以下结果:
id name
身份证名
1 acción
1acción
i've checked that i'm using the same collation in the database, table and column. 我检查过我是否在数据库,表和列中使用相同的排序规则。 so i don't know what's going wrong.
所以我不知道出了什么问题。
any idea? 任何想法? thanks!
谢谢!
I've solved this executing 我已经解决了这个执行
con.query("SET NAMES UTF8")
right before my insert query. 就在我的插入查询之前。
i hope this helps anyone having the same problem. 我希望这可以帮助遇到相同问题的任何人。 i don't know if it's the best solution.
我不知道这是否是最好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.