mysql和mysql2 gem有什么区别 [英] What the difference between mysql and mysql2 gem
问题描述
我曾经使用过 mysql
gem,但现在我经常听说 mysql2
gem。此外,它还包含在 Gemfile 中,默认位于 Rails 3.0.x
中。
使用 mysql2
gem的区别和优点是什么?
以下是来自 mysql2 gem页面的引用:
是啊......但为什么?
有人:Dude,Mysql gem works
fiiiiiine。
我:确实如此,但它只交出
你无和字符串的字段值。
让你将它们转换为
在Ruby-land中适当的Ruby类型 - 其中
的速度慢于球。
某人:OK很好,但do_mysql可以
已经给我返回的值与Ruby
对象映射到MySQL类型。
我:是的,但它的API是相当
更复杂,可以慢两倍。
I used to work with the mysql
gem, but often nowadays I hear about the mysql2
gem. Also, it is included in the Gemfile by default in Rails 3.0.x
.
What is the difference and advantages of using the mysql2
gem?
Here's a quote from the mysql2 gem page:
Yeah… but why?
Someone: Dude, the Mysql gem works fiiiiiine.
Me: It sure does, but it only hands you nil and strings for field values. Leaving you to convert them into proper Ruby types in Ruby-land - which is slow as balls.
Someone: OK fine, but do_mysql can already give me back values with Ruby objects mapped to MySQL types.
Me: Yep, but its API is considerably more complex and can be ~2x slower.
这篇关于mysql和mysql2 gem有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!