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") # or: conn = PGconn.open('dbname=test1') res = conn.exec("select * from a;")
Object
connect(pghost,
pgport, pgoptions,
pgtty, dbname, login,
passwd)
new(pghost,
pgport, pgoptions,
pgtty, dbname, login,
passwd)
open(string)
On failure, it raises PGError
exception.
db
host
user
options
port
tty
error
finish
close
reset
trace(port)
untrace
exec(sql)
PGError
exception.
query(sql)
async_exec(sql)
PGError
exception.
async_query(sql)
get_notify
insert_table(table,
array)
getline
putline(string)
endcopy
set_client_encoding
client_encoding
set_notice_processor(proc)
lo_import(file)
PGError
exception.
lo_export(oid, file)
lo_create([mode])
PGError
exception.
lo_open(oid, [mode])
PGError
exception. If mode omitted, the default is "INV_READ"
lo_unlink(oid)
The class to represent the query result tuples. The object of this class is created as the result of every query. You may need to invoke clear method for the finished object for better memory performance.
Object
status
result
fields
num_tuples
num_fields
fieldname(index)
fieldnum(name)
type(index)
size(index)
-1
if the field is variable sized.
getvalue(tup_num, field_num)
getlength(tup_num, field_num)
cmdtuples
cmdstatus
oid
nil
if
the last statement was not an INSERT
clear
The class to access large objects. The object of this class is created as the result of lo_import, lo_create, and lo_open.
Object
open([mode])
close
read([length])
write(str)
seek(offset, whence)
tell
unlink
oid
size
export(file)