开发者

What the difference between mysql and mysql2 gem

开发者 https://www.devze.com 2023-02-19 13:01 出处:网络
I used to work with the mysql gem, but often nowadays I hear about the mysql2 gem. Al开发者_如何学Pythonso, it is included in the Gemfile by default in Rails 3.0.x.

I used to work with the mysql gem, but often nowadays I hear about the mysql2 gem. Al开发者_如何学Pythonso, 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.


mysql2 is very much faster than the mysql gem. Also, apart from being effective, it also has more features and is more fun, just like Ruby on Rails.

0

精彩评论

暂无评论...
验证码 换一张
取 消