class DBI::DBD::SQLRelay::Driver

Public Class Methods

new() click to toggle source
Calls superclass method
# File SQLRelay.rb, line 43
def initialize
  super(USED_DBD_VERSION)
end

Public Instance Methods

connect(dbname, user, auth, attr) click to toggle source

dbname should have the format: “DBI:SQLRelay:host=host;port=port;socket=socket;”

Opens a connection to the sqlrelay server and authenticates with user and auth. attr is currently ignored.

# File SQLRelay.rb, line 58
def connect(dbname, user, auth, attr)

  # connect to database
  
  # dbname will have one of these formats:
  # dbi:SQLRelay:host:port
  # dbi:SQLRelay:host=xxx;port=xxx;socket=xxx;retrytime=xxx;tries=xxx
  hash = Utils.parse_params(dbname)

  if hash.has_key? "database" then
    # handle the first form
    hash["host"], hash["port"] = hash["database"], hash["host"]
  end

  # set default values if none were supplied
  hash['host']      ||= "localhost"
  hash['port']      ||= "9000"
  hash['socket']    ||= ""
  hash['retrytime'] ||= "0"
  hash['tries']     ||= "1"
  
  # TODO: what happens on connection failure? return nil?
  handle = SQLRConnection.new(hash['host'], hash['port'].to_i, 
    hash['socket'], user, auth, hash['retrytime'].to_i, hash['tries'].to_i)

  return Database.new(handle, attr)
end
driver_name() click to toggle source
# File SQLRelay.rb, line 47
def driver_name
  return "SQLRelay"
end