mysql - 我可以将 ruby​​ 哈希存储在 mysql 数据库列中吗

标签 mysql ruby hash

我想将如下所示的哈希插入到 mysql 列中,

{:sub => ["at","div.product-info"],
     1 => [["at","span#hs18Price"]],
     :avail => ["at","strong.out_stock"],
     :soffer =>  ["at","div.freebie"], 
     :stime =>["search","div[@class='costs']//span[@class='days']"],
     :scost => [300,30] }

我试过了,它抛出以下错误,

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'costs...

有什么帮助吗?

编辑:

忘记事件记录和序列化吧。我想在原始 sql 中执行此操作。

最佳答案

您需要转义散列中的单引号

关于mysql - 我可以将 ruby​​ 哈希存储在 mysql 数据库列中吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15567569/

相关文章:

algorithm - 应用程序中的密码哈希字符

mysql - CSV数据导入及数据处理

ruby - 如何在 Ruby 中读取整个文件?

ruby-on-rails - 设计 Controller 如何改变布局?

ruby-on-rails - Ruby/Rails - 在新窗口中从 Controller 打开 URL

ruby-on-rails - 如何从 hstore 列中获取二维散列作为输出?

php - 更新查询在 codeigniter 中不起作用?

php - 提交表单后如何在模态 Bootstrap 中显示 mysql 结果

php - 更新 mySql 表中的某些列?

json - 在 Perl 中,如何查询 JSON::Path 对象并返回匹配元素的路径?