8

Sequel から 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
4

2 に答える 2

14

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

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

于 2009-08-04T21:55:38.790 に答える
1

:host=>'localhost'あなたはあなたのホストが何であるか、または何でも欠けています。

また、これは純粋にパフォーマンス上の理由からであり、を有効にしてみてください: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/sequel-talk@googlegroups.com/msg02275.html

于 2009-07-17T17:31:37.527 に答える