Class | Sequel::ODBC::Database
In: | lib/sequel/adapters/odbc.rb
Parent: | Sequel::Database

### Methods

connect dataset do execute execute_dui new

### Constants

GUARDED_DRV_NAME | = | /^\{.+\}$/.freeze
DRV_NAME_GUARDS | = | '{%s}'.freeze
DISCONNECT_ERRORS | = | /\A08S01/.freeze

### Public Class methods

new(opts)

[Source]

        # File lib/sequel/adapters/odbc.rb, line 12
    12:       def initialize(opts)
    13:         super
    14:         case @opts[:db_type]
    15:         when 'mssql'
    16:           Sequel.ts_require 'adapters/odbc/mssql'
    17:           extend Sequel::ODBC::MSSQL::DatabaseMethods
    18:         when 'progress'
    19:           Sequel.ts_require 'adapters/shared/progress'
    20:           extend Sequel::Progress::DatabaseMethods
    21:         end
    22:       end

### Public Instance methods

connect(server)

[Source]

        # File lib/sequel/adapters/odbc.rb, line 24
    24:       def connect(server)
    25:         opts = server_opts(server)
    26:         if opts.include? :driver
    27:           drv = ::ODBC::Driver.new
    28:           drv.name = 'Sequel ODBC Driver130'
    29:           opts.each do |param, value|
    30:             if :driver == param and not (value =~ GUARDED_DRV_NAME)
    31:               value = DRV_NAME_GUARDS % value
    32:             end
    33:             drv.attrs[param.to_s.upcase] = value.to_s
    34:           end
    35:           db = ::ODBC::Database.new
    36:           conn = db.drvconnect(drv)
    37:         else
    38:           conn = ::ODBC::connect(opts[:database], opts[:user], opts[:password])
    39:         end
    40:         conn.autocommit = true
    41:         conn
    42:       end

dataset(opts = nil)

[Source]

        # File lib/sequel/adapters/odbc.rb, line 44
    44:       def dataset(opts = nil)
    45:         ODBC::Dataset.new(self, opts)
    46:       end

do(sql, opts={})

Alias for execute_dui

execute(sql, opts={}) {|r| ...}

[Source]

        # File lib/sequel/adapters/odbc.rb, line 48
    48:       def execute(sql, opts={})
    49:         synchronize(opts[:server]) do |conn|
    50:           begin
    51:             r = log_yield(sql){conn.run(sql)}
    52:             yield(r) if block_given?
    53:           rescue ::ODBC::Error, ArgumentError => e
    54:             raise_error(e, :disconnect=>DISCONNECT_ERRORS.match(e.message))
    55:           ensure
    56:             r.drop if r
    57:           end
    58:           nil
    59:         end
    60:       end

execute_dui(sql, opts={})

[Source]

        # File lib/sequel/adapters/odbc.rb, line 62
    62:       def execute_dui(sql, opts={})
    63:         synchronize(opts[:server]) do |conn|
    64:           begin
    65:             log_yield(sql){conn.do(sql)}
    66:           rescue ::ODBC::Error, ArgumentError => e
    67:             raise_error(e, :disconnect=>DISCONNECT_ERRORS.match(e.message))
    68:           end
    69:         end
    70:       end

[Validate]