| Class | Sequel::TinyTDS::Database |
| In: |
lib/sequel/adapters/tinytds.rb
|
| Parent: | Sequel::Database |
Transfer the :host and :user options to the :dataserver and :username options.
# File lib/sequel/adapters/tinytds.rb, line 12
12: def connect(server)
13: opts = server_opts(server)
14: opts[:dataserver] = opts[:host]
15: opts[:username] = opts[:user]
16: set_mssql_unicode_strings
17: TinyTds::Client.new(opts)
18: end
Return instance of Sequel::TinyTDS::Dataset with the given options.
# File lib/sequel/adapters/tinytds.rb, line 21
21: def dataset(opts = nil)
22: TinyTDS::Dataset.new(self, opts)
23: end
Execute the given sql on the server. If the :return option is present, its value should be a method symbol that is called on the TinyTds::Result object returned from executing the sql. The value of such a method is returned to the caller. Otherwise, if a block is given, it is yielded the result object. If no block is given and a :return is not present, nil is returned.
# File lib/sequel/adapters/tinytds.rb, line 31
31: def execute(sql, opts={})
32: synchronize(opts[:server]) do |c|
33: begin
34: m = opts[:return]
35: r = nil
36: log_yield(sql) do
37: r = c.execute(sql)
38: return r.send(m) if m
39: end
40: yield(r) if block_given?
41: rescue TinyTds::Error => e
42: raise_error(e, :disconnect=>(c.closed? || (c.respond_to?(:dead?) && c.dead?)))
43: ensure
44: r.cancel if r && c.sqlsent?
45: end
46: end
47: end
Execute the DDL sql on the database and return nil.
# File lib/sequel/adapters/tinytds.rb, line 61
61: def execute_ddl(sql, opts={})
62: execute(sql, opts.merge(:return=>:each))
63: nil
64: end
Return the number of rows modified by the given sql.
# File lib/sequel/adapters/tinytds.rb, line 50
50: def execute_dui(sql, opts={})
51: execute(sql, opts.merge(:return=>:do))
52: end