Class: Sequel::ODBC::Database

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

### Public Class methods

new(opts)

[Source]

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

### Public Instance methods

connect(server)

[Source]

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

dataset(opts = nil)

[Source]

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

do(sql, opts={})

Alias for execute_dui

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

[Source]

        # File lib/sequel/adapters/odbc.rb, line 47
    47:       def execute(sql, opts={})
    48:         log_info(sql)
    49:         synchronize(opts[:server]) do |conn|
    50:           begin
    51:             r = conn.run(sql)
    52:             yield(r) if block_given?
    53:           rescue ::ODBC::Error => e
    54:             raise_error(e)
    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:         log_info(sql)
    64:         synchronize(opts[:server]) do |conn|
    65:           begin
    66:             conn.do(sql)
    67:           rescue ::ODBC::Error => e
    68:             raise_error(e)
    69:           end
    70:         end
    71:       end

[Validate]