2009-07-17 6 views
8

SequelからMySQLに接続しようとします。これらのエラーが表示されています:Sequel gemからmysqlを接続できません

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

エラーが切り捨てられているようですか?また、あなたの関数呼び出しのホストはどこですか? –

+0

私はホストを追加しましたが、それでも同じエラーが返されます –

答えて

14

ネイティブのMySQLドライバをインストールする必要があります。純粋なルビーのものはSequelと互換性がありません。

Rubyのインストールによっては、gem install mysqlを実行するだけで十分です。しかし、純粋なRubyのmysql.rbファイルがすでにRubyのロードパスにある場合は、ロードパスからそのファイルを削除するか、Sequel.connectを呼び出す前にgem('mysql')を使用する必要があります。

1

あなたのホストが何であるかわかりません。

また、これはパフォーマンス上の理由からです。:compressを有効にしてください。それは帯域幅のトーンを節約することができます。

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

編集:それはホストでなければOK、多分それは競合ですか? http://groups.google.com/group/sequel-talk/browse_thread/thread/ee39640a92351f1?pli=1を参照してください。またhttp://www.mail-archive.com/[email protected]/msg02275.html

+0

ありがとう、 マシンにインストールされている2つのバージョンのmysql gemがあります。 –

+0

それで問題を解決できましたか? –

関連する問題