[英]How do we verify if Sequel.connect opened our SQLite3 database in Rails?
[英]How do connect from Sequel to SQLite
我的SQLite數據庫位於p:\\StockSymbols.db
我試圖通過續集gem進行連接,但它不喜歡它。
C:\Users\murth>irb irb(main):001:0> require 'sqlite3'
=> true irb(main):002:0> require 'sequel'
=> true irb(main):003:0> Sequel.sqlite('P:\\StockSymbols.db')
=> #<Sequel::SQLite::Database: {:adapter=>:sqlite, :database=>"P:\\StockSymbols.db"}> irb(main):004:0> Sequel.connect("P:\\StockSymbols.db") URI::InvalidURIError: bad URI(is not URI?): P:\StockSymbols.db
from C:/Ruby24-x64/lib/ruby/2.4.0/uri/rfc3986_parser.rb:67:in `split'
from C:/Ruby24-x64/lib/ruby/2.4.0/uri/rfc3986_parser.rb:73:in `parse'
from C:/Ruby24-x64/lib/ruby/2.4.0/uri/common.rb:231:in `parse'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/database/connecting.rb:34:in `connect'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/core.rb:121:in `connect'
from (irb):4
from C:/Ruby24-x64/bin/irb.cmd:19:in `<main>' irb(main):005:0> Sequel.connect("sqllite:///P:/StockSymbols.db") Sequel::AdapterNotFound: LoadError: cannot load such file -- sequel/adapters/sqllite
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/database/connecting.rb:88:in `load_adapter'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/database/connecting.rb:17:in `adapter_class'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/database/connecting.rb:36:in `connect'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sequel-5.13.0/lib/sequel/core.rb:121:in `connect'
from (irb):5
from C:/Ruby24-x64/bin/irb.cmd:19:in `<main>'
希望您也安裝了sqlite3。 您可能還需要在Sequel.connect
之前的同一irb會話中也require 'sqlite3'
。
另外,使用snake_case重命名數據庫。 只是一個約定。
require 'sequel'
require 'sqlite3'
DB = Sequel.connect('sqlite://your_db.db') # ./your_db.db
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.