PostgreSQL PQ protocol modules
PQueue is a package providing low-level PQ protocol classes for interacting with a PostgreSQL database. It supports version 3.0 of the protocol--the current primary version of protocol. The package also provides a basic protocol transaction class. This class keeps the state of the protocol in an interrupt safe manner, and validates the integrity of the communication as messages are received.
In general, you probably will never use this package directly, unless you are writing a driver.
package postgresql.protocol.pqueue
PQ protocol facilities
module postgresql.protocol.pqueue.cbuffer
PQ message stream
module postgresql.protocol.pqueue.element3
PQ version 3.0 elements
classes
class methods
def parse(self, data):
methods
def __eq__(self, ob):
def __repr__(self):
def __str__(self):
def serialization(self, writer):
class data
__slots__ =
()
Authentication(request, salt)
class methods
def parse(subtype, data):
methods
def __init__(self, request, salt):
def serialize(self):
properties
property salt
property request
Bind a parsed statement with the given arguments to a Portal
class methods
def parse(subtype, message_data):
methods
def __init__(self, portal, statement, args, rformats):
def serialize(self):
properties
property name
property arguments
property statement
property rformats
class methods
def parse(subtype, data):
methods
def __init__(self, format, formats):
def serialize(self):
properties
property formats
property format
Begin copying from
properties
property format
property formats
Begin copying to
properties
property format
property formats
An abstract message that is always empty
Bind reaction
Close statement or Portal
Close the connection
Flush
Null command
Null command
Parse reaction
Portal was suspended, more tuples for reading
Synchronize
Fetch results from the specified Portal
class methods
def parse(self, data):
properties
property name
property max
Execute the specified function with the given arguments
class methods
def parse(self, data):
properties
property rformat
property oid
property arguments
Function result value
class methods
def parse(self, data):
methods
def __init__(self, datum):
def serialize(self):
properties
property result
Backend cancellation information
class methods
def parse(self, data):
methods
def __init__(self, pid, key):
def serialize(self):
properties
property key
property pid
Abort the query in the specified backend
class methods
def parse(self, data):
methods
def serialize(self):
properties
property key
property pid
Discover backend's SSL support
class methods
def __new__(subtype):
def parse(self, data):
methods
def serialize(self):
Asynchronous notification message
class methods
def parse(self, data):
properties
property relation
property pid
property parameter
Parse a query with the specified argument types
class methods
def parse(self, data):
methods
def __init__(self, name, statement, argtypes):
def serialize(self):
properties
property argtypes
property name
property statement
Ready for new query
methods
def __init__(self, data):
def serialize(self):
properties
property xact_state
ShowOption(name, value) GUC variable information from backend
class methods
def parse(self, data):
methods
def __init__(self, name, value):
def serialize(self):
properties
property value
property name
An absolutely empty message. When serialized, it always yields an empty string.
Generic Close
Complete command
Describe a Portal or Prepared Statement
Password supplement
Execute the query with the given arguments
Notification message
class methods
def parse(self, data):
methods
def __repr__(self):
def serialize(self):
Initiate a connection
class methods
def parse(self, data):
methods
def __repr__(self):
def serialize(self):
Tuple attribute types
Incoming tuple
Tuple description
functions
def <lambda>(x):
def <lambda>(x):
def str_message_repr(self):
def tuple_message_repr(self):
def dict_message_repr(self):
data
AuthRequest_Cleartext =
3
AuthRequest_Crypt =
4
AuthRequest_GSS =
7
AuthRequest_GSSContinue =
8
AuthRequest_KRB4 =
1
AuthRequest_KRB5 =
2
AuthRequest_MD5 =
5
AuthRequest_OK =
0
AuthRequest_Password =
3
AuthRequest_SCMC =
6
AuthRequest_SSPI =
9
BYTE =
chr
BinaryFormat =
'\x00\x01'
BindCompleteMessage =
postgresql.protocol.pqueue.element3.BindComplete()
CloseCompleteMessage =
postgresql.protocol.pqueue.element3.CloseComplete()
CopyDoneMessage =
postgresql.protocol.pqueue.element3.CopyDone()
DictionaryType =
dict
DisconnectMessage =
postgresql.protocol.pqueue.element3.Disconnect()
FlushMessage =
postgresql.protocol.pqueue.element3.Flush()
H_struct =
<Struct object at 0x13083e0>
L_struct =
<Struct object at 0x13083c0>
NegotiateSSLMessage =
postgresql.protocol.pqueue.element3.NegotiateSSL()
NoDataMessage =
postgresql.protocol.pqueue.element3.NoData()
NullMessage =
postgresql.protocol.pqueue.element3.Null()
ObjectType =
object
ParseCompleteMessage =
postgresql.protocol.pqueue.element3.ParseComplete()
StringFormat =
'\x00\x00'
StringType =
str
SuspensionMessage =
postgresql.protocol.pqueue.element3.Suspension()
SynchronizeMessage =
postgresql.protocol.pqueue.element3.Synchronize()
TupleType =
tuple
UNBYTE =
ord
VoidMessage =
postgresql.protocol.pqueue.element3.Void()
pack =
struct.pack
unpack =
struct.unpack
module postgresql.protocol.pqueue.buffer
This is an abstraction module that provides the working buffer implementation. If a C compiler is not available on the system that built the package, the slower `postgresql.protocol.pqueue.pbuffer` module can be used in `postgresql.protocol.pqueue.cbuffer`'s absence. This provides a convenient place to import the necessary module without concerning the local code with the details.
module postgresql.protocol.pqueue.client3
PQ version 3.0 client transactions
classes
An exception that occurs when an unexpected message was received.
methods
A transaction object is state machine that is initialized with the request
messages to be sent to the server. It provides the messages to be sent and
takes the response messages for order and integrity validation:
Transaction([postgresql.protocol.pqueue.element3.Message(), ..])
A message must be one of:
* `postgresql.protocol.pqueue.element3.Query`
* `postgresql.protocol.pqueue.element3.Function`
* `postgresql.protocol.pqueue.element3.Parse`
* `postgresql.protocol.pqueue.element3.Bind`
* `postgresql.protocol.pqueue.element3.Describe`
* `postgresql.protocol.pqueue.element3.Close`
* `postgresql.protocol.pqueue.element3.Execute`
* `postgresql.protocol.pqueue.element3.Synchronize`
* `postgresql.protocol.pqueue.element3.Flush`
methods
def __init__(self, commands):
Initialize a `Transaction` instance using the given commands. Commands are `postgresql.protocol.pqueue.element3.Message` instances. (Of course, subclasses thereof.)
def __repr__(self):
def put_copydata(self, messages):
In the context of a copy, `put_copydata` is used as a fast path for storing `element.CopyData` messages. When a non-`element.CopyData.type` message is received, it reverts the ``state`` attribute back to `standard_put` to normally process the message..
def put_tupledata(self, messages):
Fast path used when inside an Execute command. As soon as tuple data is seen.
def reset(self):
Reset the `Transaction` instance to its initial state. Allows reuse without recreation.
def reverse(self):
A generator that producing an iterator of completed messages in reverse order. Last in, first out.
def sent(self):
empty messages and switch state to receiving
def sent_from_stdin(self):
The state method for sending copy data.
def standard_put(self, messages):
Attempt to forward the state of the transaction using the given messages. "put" messages into the transaction for processing. If an invalid command is initialized on the `Transaction` object, an `IndexError` will be thrown.
def standard_sent(self):
empty messages and switch state to receiving
class data
CopyFailMessage =
postgresql.protocol.pqueue.element3.CopyFail('invalid termination')fatal =
None
state =
(None, None)
initial_state =
((), (0, 0), (0, 0))
module postgresql.protocol.pqueue.version
PQ version class
classes
Version((major, minor)) -> Version Version serializer and parser.
class methods
def __new__(subtype, (major, minor)):
def parse(self, data):
methods
def __int__(self):
def __repr__(self):
def __str__(self):
properties
property major
property minor
data
CancelRequestCode =
1234.5678
NegotiateSSLCode =
1234.5679
TupleType =
tuple
V2_0 =
2.0
V3_0 =
3.0
pack =
struct.pack
unpack =
struct.unpack
module postgresql.protocol.pqueue.pbuffer
imports
import struct
classes
provide a message stream from a data stream
methods
def __init__(self):
def __len__(self):
number of messages in buffer
def __next__(self):
def _get_message(self):
[internal] remove the given amount of data
def has_message(self):
if the buffer has a message available
def next(self):
def next_message(self):
def truncate(self):
remove all data in the buffer
def write(self, data):