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

### Methods

connect 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:           @dataset_class = Sequel::ODBC::MSSQL::Dataset
    19:           set_mssql_unicode_strings
    20:         when 'progress'
    21:           Sequel.ts_require 'adapters/shared/progress'
    22:           extend Sequel::Progress::DatabaseMethods
    23:           extend_datasets(Sequel::Progress::DatasetMethods)
    24:         when 'db2'
    25:           Sequel.ts_require 'adapters/odbc/db2'
    26:           extend Sequel::ODBC::DB2::DatabaseMethods
    27:           @dataset_class = Sequel::ODBC::DB2::Dataset
    28:         end
    29:       end

### Public Instance methods

connect(server)

[Source]

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

do(sql, opts={})

Alias for execute_dui

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

[Source]

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

execute_dui(sql, opts={})

[Source]

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

[Validate]