Class: PGconn

Inherits:
Object
  • Object
show all
Defined in:
lib/postgres-pr/postgres-compat.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options, tty, database, user, auth) ⇒ PGconn

Returns a new instance of PGconn.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/postgres-pr/postgres-compat.rb', line 11

def initialize(host, port, options, tty, database, user, auth)
  uri =
  if host.nil?
    nil
  elsif host[0] != ?/
    "tcp://#{ host }:#{ port }"
  else
    "unix:#{ host }/.s.PGSQL.#{ port }"
  end
  @host = host
  @db = database
  @user = user
  @conn = PostgresPR::Connection.new(database, user, auth, uri)
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



30
31
32
# File 'lib/postgres-pr/postgres-compat.rb', line 30

def db
  @db
end

#hostObject (readonly)

Returns the value of attribute host.



30
31
32
# File 'lib/postgres-pr/postgres-compat.rb', line 30

def host
  @host
end

#userObject (readonly)

Returns the value of attribute user.



30
31
32
# File 'lib/postgres-pr/postgres-compat.rb', line 30

def user
  @user
end

Class Method Details

.escape(str) ⇒ Object



42
43
44
# File 'lib/postgres-pr/postgres-compat.rb', line 42

def self.escape(str)
  str.gsub("'","''").gsub("\\", "\\\\\\\\")
end

.quote_ident(name) ⇒ Object



54
55
56
# File 'lib/postgres-pr/postgres-compat.rb', line 54

def self.quote_ident(name)
  %("#{name}")
end

Instance Method Details

#closeObject



26
27
28
# File 'lib/postgres-pr/postgres-compat.rb', line 26

def close
  @conn.close
end

#notice_processorObject



46
47
48
# File 'lib/postgres-pr/postgres-compat.rb', line 46

def notice_processor
  @conn.notice_processor
end

#notice_processor=(np) ⇒ Object



50
51
52
# File 'lib/postgres-pr/postgres-compat.rb', line 50

def notice_processor=(np)
  @conn.notice_processor = np
end

#query(sql) ⇒ Object Also known as: exec



32
33
34
# File 'lib/postgres-pr/postgres-compat.rb', line 32

def query(sql)
  PGresult.new(@conn.query(sql))
end

#transaction_statusObject



38
39
40
# File 'lib/postgres-pr/postgres-compat.rb', line 38

def transaction_status
  @conn.transaction_status
end