我正在尝试将MS SQL数据库连接到我的Ruby程序,以便运行只读查询。我尝试使用Sequel,Ruby-DBI和TinyTDS无济于事。
这是我与Sequel联系的代码:
require 'rubygems'
require 'sequel'
hostname = 'DB name'
username = 'username here'
password = 'password here'
port = 1433
connection_instance = Sequel.connect(:host => hostname, :user => username, :password => password, :test => true)
以下是我收到的错误:
C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
: LoadError: cannot load such file -- sequel/adapters/ (Sequel::AdapterNotFound)
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.35.0/lib/sequel/database/connecting.rb:98:in `load_adapter'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.35.0/lib/sequel/database/connecting.rb:28:in `adapter_class'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.35.0/lib/sequel/database/connecting.rb:56:in `connect'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.35.0/lib/sequel/core.rb:108:in `connect'
from snippet.rb:11:in `<main>'
答案 0 :(得分:0)
我使用tinytds:
@db = Sequel.tinytds(
:host => options['dbserver'],
:database=> options['db'],
:user => options['dbuser'],
:password=> options['dbpwd'],
#:timeout => options['timeout'], #for long lasting requests
)
在过去,我使用了ado,但有了ado我遇到了问题(编码错误,超时......)