Parent

Class/Module Index [+]

Quicksearch

Sequel::Fdbsql::Connection

Connection specific methods for Fdbsql with pg

Constants

DISCONNECT_ERROR_RE

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

new(db, opts) click to toggle source

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

# File lib/sequel/adapters/fdbsql.rb, line 213
def initialize(db, opts)
  connect_opts = {
    :host => opts[:host] || 'localhost',
    :port => opts[:port] || 15432,
    :dbname => opts[:database],
    :user => opts[:user],
    :password => opts[:password],
    :hostaddr => opts[:hostaddr],
    :connect_timeout => opts[:connect_timeout] || 20,
    :sslmode => opts[:sslmode]
  }.delete_if{|key, value| value.nil? or (value.respond_to?(:empty?) and value.empty?)}
  super(connect_opts)

  @db = db
  @prepared_statements = {}

  if opts[:notice_receiver]
    set_notice_receiver(opts[:notice_receiver])
  else
    # Swallow warnings
    set_notice_receiver{|proc| }
  end
end

Public Instance Methods

close() click to toggle source

Close the connection.

# File lib/sequel/adapters/fdbsql.rb, line 238
def close
  super
rescue PGError, IOError
end
execute(sql, args=nil) click to toggle source

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

# File lib/sequel/adapters/fdbsql.rb, line 245
def execute(sql, args=nil)
  q = query(sql, args)
  block_given? ? yield(q) : q.cmd_tuples
end
execute_prepared_statement(name, args) click to toggle source

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

# File lib/sequel/adapters/fdbsql.rb, line 252
def execute_prepared_statement(name, args)
  check_disconnect_errors{exec_prepared(name, args)}
end
prepare(name, sql) click to toggle source

Prepare a statement for later use.

# File lib/sequel/adapters/fdbsql.rb, line 257
def prepare(name, sql)
  check_disconnect_errors{super}
end
query(sql, args=nil) click to toggle source

Execute the given query and return the results.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.