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

Methods

Constants

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

Public Instance methods

[Source]

    # File lib/sequel/adapters/odbc.rb, line 12
12:       def connect(server)
13:         opts = server_opts(server)
14:         conn = if opts.include?(:drvconnect)
15:           ::ODBC::Database.new.drvconnect(opts[:drvconnect])
16:         elsif opts.include?(:driver)
17:           Deprecation.deprecate("The odbc driver's handling of the :driver option is thought to be broken and will probably be removed in the future. If you are successfully using it, please contact the developers.")
18:           drv = ::ODBC::Driver.new
19:           drv.name = 'Sequel ODBC Driver130'
20:           opts.each do |param, value|
21:             if :driver == param and not (value =~ GUARDED_DRV_NAME)
22:               value = DRV_NAME_GUARDS % value
23:             end
24:             drv.attrs[param.to_s.upcase] = value.to_s
25:           end
26:           ::ODBC::Database.new.drvconnect(drv)
27:         else
28:           ::ODBC::connect(opts[:database], opts[:user], opts[:password])
29:         end
30:         conn.autocommit = true
31:         conn
32:       end

[Source]

    # File lib/sequel/adapters/odbc.rb, line 34
34:       def disconnect_connection(c)
35:         c.disconnect
36:       end

[Source]

    # File lib/sequel/adapters/odbc.rb, line 38
38:       def execute(sql, opts=OPTS)
39:         synchronize(opts[:server]) do |conn|
40:           begin
41:             r = log_yield(sql){conn.run(sql)}
42:             yield(r) if block_given?
43:           rescue ::ODBC::Error, ArgumentError => e
44:             raise_error(e)
45:           ensure
46:             r.drop if r
47:           end
48:           nil
49:         end
50:       end

[Source]

    # File lib/sequel/adapters/odbc.rb, line 52
52:       def execute_dui(sql, opts=OPTS)
53:         synchronize(opts[:server]) do |conn|
54:           begin
55:             log_yield(sql){conn.do(sql)}
56:           rescue ::ODBC::Error, ArgumentError => e
57:             raise_error(e)
58:           end
59:         end
60:       end

[Validate]