Class | Sequel::ADO::Database |
In: |
lib/sequel/adapters/ado.rb
|
Parent: | Sequel::Database |
CommandTimeout | = | opts[:command_timeout] if opts[:command_timeout] |
Provider | = | opts[:provider] if opts[:provider] |
# File lib/sequel/adapters/ado.rb, line 9 9: def initialize(opts) 10: super 11: case @opts[:conn_string] 12: when /Microsoft\.(Jet|ACE)\.OLEDB/io 13: Sequel.ts_require 'adapters/shared/access' 14: extend Sequel::Access::DatabaseMethods 15: else 16: @opts[:driver] ||= 'SQL Server' 17: case @opts[:driver] 18: when 'SQL Server' 19: Sequel.ts_require 'adapters/ado/mssql' 20: extend Sequel::ADO::MSSQL::DatabaseMethods 21: set_mssql_unicode_strings 22: end 23: end 24: end
In addition to the usual database options, the following options have an effect:
:command_timeout : | Sets the time in seconds to wait while attempting to execute a command before cancelling the attempt and generating an error. Specifically, it sets the ADO CommandTimeout property. If this property is not set, the default of 30 seconds is used. |
:driver : | The driver to use in the ADO connection string. If not provided, a default of "SQL Server" is used. |
:conn_string : | The full ADO connection string. If this is provided, the usual options are ignored. |
:provider : | Sets the Provider of this ADO connection (for example, "SQLOLEDB"). If you don‘t specify a provider, the default one used by WIN32OLE has major problems, such as creating a new native database connection for every query, which breaks things such as temporary tables. |
Pay special attention to the :provider option, as without specifying a provider, many things will be broken. The SQLNCLI10 provider appears to work well if you are connecting to Microsoft SQL Server, but it is not the default as that would break backwards compatability.
# File lib/sequel/adapters/ado.rb, line 46 46: def connect(server) 47: opts = server_opts(server) 48: s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}" 49: handle = WIN32OLE.new('ADODB.Connection') 50: handle.CommandTimeout = opts[:command_timeout] if opts[:command_timeout] 51: handle.Provider = opts[:provider] if opts[:provider] 52: handle.Open(s) 53: handle 54: end
# File lib/sequel/adapters/ado.rb, line 56 56: def dataset(opts = nil) 57: ADO::Dataset.new(self, opts) 58: end