Class | PGconn |
In: |
postgres.c
|
Parent: | Object |
The class to access PostgreSQL database. All other functionality of libpq save the large object to a file.
For example, to send query to the database on the localhost:
require "postgres" conn = PGconn.connect("localhost", 5432, "", "", "test1") res = conn.exec("select * from a;")
See the PGresult class for information on working with the results of a query.
Returns a SQL-safe version of the String str. Unlike quote, does not wrap the String in ’…’.
Escapes binary data for use within an SQL command with the type bytea.
Certain byte values must be escaped (but all byte values may be escaped) when used as part of a bytea literal in an SQL statement. In general, to escape a byte, it is converted into the three digit octal number equal to the octet value, and preceded by two backslashes. The single quote (’) and backslash (\) characters have special alternative escape sequences. escape_bytea performs this operation, escaping only the minimally required bytes.
See the PostgreSQL 7.4 Documentation on PQescapeBytea for more information.
If obj is a Number, String, Array, nil, true, or false then quote returns a String representation of that object safe for use in PostgreSQL.
If obj is not one of the above classes and a block is supplied to quote, the block is invoked, passing along the object. The return value from the block is returned as a string.
If obj is not one of the recognized classes andno block is supplied, a PGError is raised.
Sends an asynchronous SQL query request specified by sql to the PostgreSQL. Returns an Array as the resulting tuple on success. On failure, it returns nil, and the error details can be obtained by error.
Reads a line from the backend server into internal buffer. Returns nil for EOF, +0+ for success, +1+ for buffer overflowed. You need to ensure single "." from backend to confirm transmission completion. The sample program psql.rb (see source for postgres) treats this copy protocol right.
Sends the string to the backend server. Users must send a single "." to denote the end of data transmission.
Sends SQL query request specified by sql to the PostgreSQL. Returns an Array as the resulting tuple on success. On failure, it returns nil, and the error details can be obtained by error.