我在我的Rails应用程序中使用Sequel而不是Active Record。
如何配置它并连接到我的数据库?目前我正在使用
DB = Sequel.connect(ENV['DATABASE_URL'])
但我收到了错误:
/home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `require': LoadError: cannot load such file -- sequel/adapters/sqlite3 (Sequel::AdapterNotFound)
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `block in tsk_require'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:100:in `block in check_requiring_thread'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:97:in `synchronize'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:97:in `check_requiring_thread'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `tsk_require'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:25:in `adapter_class'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:55:in `connect'
from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:147:in `connect'
from benchmarks/bm_sequel_create_string_columns.rb:4:in `<main>'
当我放ENV['DATABASE_URL']
时,我得到以下输出:
sqlite3::memory:
正确的方法是什么?
答案 0 :(得分:1)
使用Sequel gem时,适配器称为sqlite
,而不是sqlite3
。