Class: PGconn
- Inherits:
-
Object
- Object
- PGconn
- Defined in:
- lib/postgres-pr/postgres-compat.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(host, port, options, tty, database, user, auth) ⇒ PGconn
constructor
A new instance of PGconn.
- #notice_processor ⇒ Object
- #notice_processor=(np) ⇒ Object
- #query(sql) ⇒ Object (also: #exec)
- #transaction_status ⇒ Object
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, , 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
#db ⇒ Object (readonly)
Returns the value of attribute db.
30 31 32 |
# File 'lib/postgres-pr/postgres-compat.rb', line 30 def db @db end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
30 31 32 |
# File 'lib/postgres-pr/postgres-compat.rb', line 30 def host @host end |
#user ⇒ Object (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
#close ⇒ Object
26 27 28 |
# File 'lib/postgres-pr/postgres-compat.rb', line 26 def close @conn.close end |
#notice_processor ⇒ Object
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_status ⇒ Object
38 39 40 |
# File 'lib/postgres-pr/postgres-compat.rb', line 38 def transaction_status @conn.transaction_status end |