Class Sequel::ADO::Database
In: lib/sequel/adapters/ado.rb
Parent: Sequel::Database

Methods

connect   dataset   do   execute   new  

Constants

CommandTimeout = opts[:command_timeout] if opts[:command_timeout]
Provider = opts[:provider] if opts[:provider]

Public Class methods

[Source]

    # File lib/sequel/adapters/ado.rb, line 9
 9:       def initialize(opts)
10:         super(opts)
11:         opts[:driver] ||= 'SQL Server'
12:         case opts[:driver]
13:         when 'SQL Server'
14:           Sequel.require 'adapters/ado/mssql'
15:           extend Sequel::ADO::MSSQL::DatabaseMethods
16:         end
17:       end

Public Instance methods

Connect to the database. 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.
  • :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")

[Source]

    # File lib/sequel/adapters/ado.rb, line 29
29:       def connect(server)
30:         opts = server_opts(server)
31:         s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}"
32:         handle = WIN32OLE.new('ADODB.Connection')
33:         handle.CommandTimeout = opts[:command_timeout] if opts[:command_timeout]
34:         handle.Provider = opts[:provider] if opts[:provider]
35:         handle.Open(s)
36:         handle
37:       end

[Source]

    # File lib/sequel/adapters/ado.rb, line 39
39:       def dataset(opts = nil)
40:         ADO::Dataset.new(self, opts)
41:       end
do(sql, opts={})

Alias for execute

[Source]

    # File lib/sequel/adapters/ado.rb, line 43
43:       def execute(sql, opts={})
44:         log_info(sql)
45:         synchronize(opts[:server]) do |conn|
46:           begin
47:             r = conn.Execute(sql)
48:             yield(r) if block_given?
49:           rescue ::WIN32OLERuntimeError => e
50:             raise_error(e)
51:           end
52:         end
53:         nil
54:       end

[Validate]