Class/Module Index [+]

Quicksearch

Sequel::ADO::Database

Public Class Methods

new(opts) click to toggle source
# File lib/sequel/adapters/ado.rb, line 9
def initialize(opts)
  super
  @opts[:driver] ||= 'SQL Server'
  case @opts[:driver]
  when 'SQL Server'
    Sequel.ts_require 'adapters/ado/mssql'
    extend Sequel::ADO::MSSQL::DatabaseMethods
  end
end

Public Instance Methods

connect(server) click to toggle source

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 39
def connect(server)
  opts = server_opts(server)
  s = opts[:conn_string] || "driver=#{opts[:driver]};server=#{opts[:host]};database=#{opts[:database]}#{";uid=#{opts[:user]};pwd=#{opts[:password]}" if opts[:user]}"
  handle = WIN32OLE.new('ADODB.Connection')
  handle.CommandTimeout = opts[:command_timeout] if opts[:command_timeout]
  handle.Provider = opts[:provider] if opts[:provider]
  handle.Open(s)
  handle
end
dataset(opts = nil) click to toggle source
# File lib/sequel/adapters/ado.rb, line 49
def dataset(opts = nil)
  ADO::Dataset.new(self, opts)
end
do(sql, opts={}) click to toggle source
Alias for: execute
execute(sql, opts={}) click to toggle source
# File lib/sequel/adapters/ado.rb, line 53
def execute(sql, opts={})
  synchronize(opts[:server]) do |conn|
    begin
      r = log_yield(sql){conn.Execute(sql)}
      yield(r) if block_given?
    rescue ::WIN32OLERuntimeError => e
      raise_error(e)
    end
  end
  nil
end
Also aliased as: do

[Validate]

Generated with the Darkfish Rdoc Generator 2.