9.3. Connection object: pgobject

Table of Contents
query — executes a SQL command
reset — resets the connection
close — close the database connection
fileno — returns the socket used to connect to the database
getnotify — gets the last notify from the server
inserttable — inserts a list into a table
putline — writes a line to the server socket [DA]
getline — gets a line from server socket [DA]
endcopy — synchronizes client and server [DA]
locreate — creates of large object in the database [LO]
getlo — builds a large object from given oid [LO]
loimport — imports a file to a PostgreSQL large object [LO]

This object handles a connection to the PostgreSQL database. It embeds and hides all the parameters that define this connection, leaving just really significant parameters in function calls.

Some methods give direct access to the connection socket. They are specified by the tag [DA]. Do not use them unless you really know what you are doing. If you prefer disabling them, set the -DNO_DIRECT option in the Python Setup file.

Some other methods give access to large objects. if you want to forbid access to these from the module, set the -DNO_LARGE option in the Python Setup file. These methods are specified by the tag [LO].

Every pgobject defines a set of read-only attributes that describe the connection and its status. These attributes are:

host

the host name of the server (string)

port

the port of the server (integer)

db

the selected database (string)

options

the connection options (string)

tty

the connection debug terminal (string)

user

user name on the database system (string)

status

the status of the connection (integer: 1 - OK, 0 - BAD)

error

the last warning/error message from the server (string)