Class: PGconn

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

Constant Summary collapse

PQTRANS_IDLE =

(connection idle)

0
PQTRANS_INTRANS =

(idle, within transaction block)

2
PQTRANS_INERROR =

(idle, within failed transaction)

3
PQTRANS_UNKNOWN =

(cannot determine status)

4

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.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/postgres-pr/pg-compat.rb', line 17

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.



36
37
38
# File 'lib/postgres-pr/pg-compat.rb', line 36

def db
  @db
end

#hostObject (readonly)

Returns the value of attribute host.



36
37
38
# File 'lib/postgres-pr/pg-compat.rb', line 36

def host
  @host
end

#userObject (readonly)

Returns the value of attribute user.



36
37
38
# File 'lib/postgres-pr/pg-compat.rb', line 36

def user
  @user
end

Class Method Details

.escape(str) ⇒ Object



48
49
50
# File 'lib/postgres-pr/pg-compat.rb', line 48

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

.quote_ident(name) ⇒ Object



64
65
66
# File 'lib/postgres-pr/pg-compat.rb', line 64

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

Instance Method Details

#closeObject



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

def close
  @conn.close
end

#escape(str) ⇒ Object



52
53
54
# File 'lib/postgres-pr/pg-compat.rb', line 52

def escape(str)
  self.class.escape(str)
end

#notice_processorObject



56
57
58
# File 'lib/postgres-pr/pg-compat.rb', line 56

def notice_processor
  @conn.notice_processor
end

#notice_processor=(np) ⇒ Object



60
61
62
# File 'lib/postgres-pr/pg-compat.rb', line 60

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

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



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

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

#transaction_statusObject



44
45
46
# File 'lib/postgres-pr/pg-compat.rb', line 44

def transaction_status
  @conn.transaction_status
end