class Sequel::ODBC::Database

  1. lib/sequel/adapters/odbc.rb
Superclass: Sequel::Database

Public Instance methods

connect(server)
[show source]
   # File lib/sequel/adapters/odbc.rb
14 def connect(server)
15   opts = server_opts(server)
16   conn = if opts.include?(:drvconnect)
17     ::ODBC::Database.new.drvconnect(opts[:drvconnect])
18   elsif opts.include?(:driver)
19     drv = ::ODBC::Driver.new
20     drv.name = 'Sequel ODBC Driver130'
21     opts.each do |param, value|
22       if :driver == param && value !~ /\A\{.+\}\z/
23         value = "{#{value}}"
24       end
25       drv.attrs[param.to_s.upcase] = value.to_s
26     end
27     ::ODBC::Database.new.drvconnect(drv)
28   else
29     ::ODBC::connect(opts[:database], opts[:user], opts[:password])
30   end
31   conn.autocommit = true
32   conn
33 end
disconnect_connection(c)
[show source]
   # File lib/sequel/adapters/odbc.rb
35 def disconnect_connection(c)
36   c.disconnect
37 end
execute(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/odbc.rb
39 def execute(sql, opts=OPTS)
40   synchronize(opts[:server]) do |conn|
41     begin
42       r = log_connection_yield(sql, conn){conn.run(sql)}
43       yield(r) if defined?(yield)
44     rescue ::ODBC::Error, ArgumentError => e
45       raise_error(e)
46     ensure
47       r.drop if r
48     end
49     nil
50   end
51 end
execute_dui(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/odbc.rb
53 def execute_dui(sql, opts=OPTS)
54   synchronize(opts[:server]) do |conn|
55     begin
56       log_connection_yield(sql, conn){conn.do(sql)}
57     rescue ::ODBC::Error, ArgumentError => e
58       raise_error(e)
59     end
60   end
61 end