2009-07-17 14 views
8

Cuando intento conectarme a MySQL desde Sequel. Me estoy haciendo estos errores:No se puede conectar mysql desde Sequel gem

require 'rubygems' 
     require 'sequel' 
     DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx') 
     DB.tables 
    Sequel::DatabaseConnectionError: NameError uninitialized constant Mysql::CLIENT_MULTI_RESULTS 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:98:in `connect' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:92:in `initialize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `call' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `make_new' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:153:in `available' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:144:in `acquire' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `synchronize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `acquire' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:105:in `hold' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:471:in `synchronize' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:128:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:314:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:342:in `execute' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:298:in `fetch_rows' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset.rb:185:in `each' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/dataset/convenience.rb:156:in `map' 
     from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/shared/mysql.rb:60:in `tables' 
     from (irb):6irb(main):007:0> Sequel::DatabaseConnectionError: NameErro 
+0

Parece que su error se truncó? Además, ¿dónde está el host en su llamada de función? –

+0

He añadido el host pero sigue arrojando el mismo error –

Respuesta

14

Necesita instalar el controlador MySQL nativo, el ruby ​​puro no es compatible con Sequel.

Dependiendo de su instalación de Ruby, simplemente hacer gem install mysql puede ser suficiente. Sin embargo, si el archivo Ruby mysql.rb puro ya está en su ruta de carga de Ruby, debe eliminarlo de la ruta de carga o usar gem('mysql') antes de llamar al Sequel.connect.

1

Te estas perdiendo el :host=>'localhost' o lo que su anfitrión es.

Además, y esto es solo por razones de rendimiento, debe intentar habilitar :compress. Puede ahorrar una TONELADA de ancho de banda.

http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html

Editar: OK, si no es el anfitrión, tal vez es un conflicto? Ver http://groups.google.com/group/sequel-talk/browse_thread/thread/ee39640a92351f1?pli=1. También http://www.mail-archive.com/[email protected]/msg02275.html

+0

gracias, Tengo dos versiones de mysql gem instaladas en la máquina. –

+0

¿Logró solucionar el problema entonces? –

Cuestiones relacionadas