>>> conn.pgconn.trace(sys.stderr.fileno())
>>> conn.pgconn.set_trace_flags(pq.Trace.SUPPRESS_TIMESTAMPS | pq.Trace.REGRESS_MODE)
>>> conn.execute("select now()")
F 13 Parse "" "BEGIN" 0
F 14 Bind "" "" 0 0 1 0
F 6 Describe P ""
F 9 Execute "" 0
F 4 Sync
B 4 ParseComplete
B 4 BindComplete
B 4 NoData
B 10 CommandComplete "BEGIN"
B 5 ReadyForQuery T
F 17 Query "select now()"
B 28 RowDescription 1 "now" NNNN 0 NNNN 8 -1 0
B 39 DataRow 1 29 '2022-09-14 14:12:16.648035+02'
B 13 CommandComplete "SELECT 1"
B 5 ReadyForQuery T
<psycopg.Cursor [TUPLES_OK] [INTRANS] (database=postgres) at 0x7f18a18ba040>
>>> conn.pgconn.untrace()
pgresult_ptr
The pointer to the underlying PGresult
structure, as integer.
None
if the result was cleared.
The value can be used to pass the structure to libpq functions which
psycopg doesn’t (currently) wrap, either in C or in Python using FFI
libraries such as ctypes
.
class psycopg.pq.PGcancelConn
Token to handle non-blocking cancellation requests.
Created by PGconn.cancel_conn()
.
start() → None
Requests that the server abandons processing of the current command
in a non-blocking manner.
See PQcancelStart
for details.
blocking() → None
Requests that the server abandons processing of the current command
in a blocking manner.
See PQcancelBlocking
for details.
finish() → None
Free the data structure created by PQcancelCreate()
.
Automatically invoked by __del__()
.
See PQcancelFinish()
for details.
class psycopg.pq.PGcancel
Token to cancel the current operation on a connection.
Created by PGconn.get_cancel()
.
free() → None
Free the data structure created by PQgetCancel()
.
Automatically invoked by __del__()
.
See PQfreeCancel()
for details.
class psycopg.pq.ConnStatus(value)
Current status of the connection.
There are other values in this enum, but only OK
and BAD
are seen
after a connection has been established. Other statuses might only be seen
during the connection phase and are considered internal.
ALLOCATED
is only expected to be returned by PGcancelConn.status
.
See also
PQstatus()
and PQcancelStatus()
return this value.
OK = 0
class psycopg.pq.PollingStatus(value)
The status of the socket during a connection.
If READING
or WRITING
you may select before polling again.
See also
PQconnectPoll
for a description of these states.
FAILED = 0
class psycopg.pq.PipelineStatus(value)
Pipeline mode status of the libpq connection.
See also
PQpipelineStatus
for a description of these states.
OFF = 0
class psycopg.pq.Format(value)
Enum representing the format of a query argument or return value.
These values are only the ones managed by the libpq. psycopg
may also
support automatically-chosen values: see psycopg.adapt.PyFormat
.
TEXT = 0
class psycopg.pq.DiagnosticField(value)
Fields in an error report.
Available attributes:
SEVERITY
SEVERITY_NONLOCALIZED
SQLSTATE
MESSAGE_PRIMARY
MESSAGE_DETAIL
MESSAGE_HINT
STATEMENT_POSITION
INTERNAL_POSITION
INTERNAL_QUERY
CONTEXT
SCHEMA_NAME
TABLE_NAME
COLUMN_NAME
DATATYPE_NAME
CONSTRAINT_NAME
SOURCE_FILE
SOURCE_LINE
SOURCE_FUNCTION
See also
PQresultErrorField
for a description of these values.
class psycopg.pq.Trace(value)
Enum to control tracing of the client/server communication.
See also
PQsetTraceFlags
for a description of these values.
SUPPRESS_TIMESTAMPS = 1
DiagnosticField.SEVERITY_NONLOCALIZED
DiagnosticField.SQLSTATE
DiagnosticField.MESSAGE_PRIMARY
DiagnosticField.MESSAGE_DETAIL
DiagnosticField.MESSAGE_HINT
DiagnosticField.STATEMENT_POSITION
DiagnosticField.INTERNAL_POSITION
DiagnosticField.INTERNAL_QUERY
DiagnosticField.CONTEXT
DiagnosticField.SCHEMA_NAME
DiagnosticField.TABLE_NAME
DiagnosticField.COLUMN_NAME
DiagnosticField.DATATYPE_NAME
DiagnosticField.CONSTRAINT_NAME
DiagnosticField.SOURCE_FILE
DiagnosticField.SOURCE_LINE
DiagnosticField.SOURCE_FUNCTION
Ping.OK
Ping.REJECT
Ping.NO_RESPONSE
Ping.NO_ATTEMPT
Trace