Как подключиться из сиквела к SQLite - PullRequest
0 голосов
/ 09 октября 2018

Моя база данных 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>'

1 Ответ

0 голосов
/ 09 октября 2018

Надеюсь, у вас установлен sqlite3.Вам, вероятно, также необходимо require 'sqlite3' в том же сеансе irb перед Sequel.connect.

Также переименуйте БД, используя snake_case.Просто соглашение.

require 'sequel'
require 'sqlite3'

DB = Sequel.connect('sqlite://your_db.db') # ./your_db.db
...