Sequel gem & MySQL (Ruby + Windows): load mysql.so file, not mysql.rb
Using ruby gem 'sequel', when I attempt Sequel.connect("mysql://localhost")
, I get the following error:
Sequel::AdapterNotFound: LoadError: require 'mysql' did not define Mysql::CLIENT_MULTI_RESULTS!
You are probably using the pure ruby mysql.rb driver,
which Sequel does not support. You need to install
the C ba开发者_如何学Csed adapter, and make sure that the mysql.so
file is loaded instead of the mysql.rb file.
How can I get this gem to connect to a MySQL server?
Sys: Win XP, Ruby 1.8.7, Mysql 5.1.51
Found the solution on this thread: Unable to connect mysql from Sequel gem
Call gem('mysql')
to specify use of the native sql driver before Sequel.connect()
.
(Upvotes for Jeremy Evans)
Sequel is an ORM on top of existing Database adapters.
The error you're receiving is because mysql
gem has not been installed.
You should be able to solve this problem doing gem install mysql
Since MySQL gem on Windows is provided as binaries, it is very sensible in relation to the dependency of libmysql.dll
available in your system.
I recommend you the following tutorial I put together to cover the proper installation of the gem against modern versions of MySQL:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
Hope this helps.
精彩评论