Class Sequel::Fdbsql::Connection
In: lib/sequel/adapters/fdbsql.rb
Parent: PG::Connection

Connection specific methods for Fdbsql with pg

Methods

Constants

DISCONNECT_ERROR_RE = /\A(?:could not receive data from server|no connection to the server|connection not open|connection is closed)/   Regular expression for error messages that note that the connection is closed.

Attributes

prepared_statements  [RW]  Hash of prepared statements for this connection. Keys are string names of the server side prepared statement, and values are SQL strings.

Public Class methods

Create a new connection to the FoundationDB SQL Layer. See Database#connect.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 213
213:       def initialize(db, opts)
214:         connect_opts = {
215:           :host => opts[:host] || 'localhost',
216:           :port => opts[:port] || 15432,
217:           :dbname => opts[:database],
218:           :user => opts[:user],
219:           :password => opts[:password],
220:           :hostaddr => opts[:hostaddr],
221:           :connect_timeout => opts[:connect_timeout] || 20,
222:           :sslmode => opts[:sslmode]
223:         }.delete_if{|key, value| value.nil? or (value.respond_to?(:empty?) and value.empty?)}
224:         super(connect_opts)
225: 
226:         @db = db
227:         @prepared_statements = {}
228: 
229:         if opts[:notice_receiver]
230:           set_notice_receiver(opts[:notice_receiver])
231:         else
232:           # Swallow warnings
233:           set_notice_receiver{|proc| }
234:         end
235:       end

Public Instance methods

Close the connection.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 238
238:       def close
239:         super
240:       rescue PGError, IOError
241:       end

Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 245
245:       def execute(sql, args=nil)
246:         q = query(sql, args)
247:         block_given? ? yield(q) : q.cmd_tuples
248:       end

Execute the prepared statement of the given name, binding the given args.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 252
252:       def execute_prepared_statement(name, args)
253:         check_disconnect_errors{exec_prepared(name, args)}
254:       end

Prepare a statement for later use.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 257
257:       def prepare(name, sql)
258:         check_disconnect_errors{super}
259:       end

Execute the given query and return the results.

[Source]

     # File lib/sequel/adapters/fdbsql.rb, line 262
262:       def query(sql, args=nil)
263:         args = args.map{|v| @db.bound_variable_arg(v, self)} if args
264:         check_disconnect_errors{super}
265:       end

[Validate]