The object is usually returned by `Connection.info`.
.. autoattribute:: status
+
+ The status can be one of a number of values. However, only two of
+ these are seen outside of an asynchronous connection procedure:
+ `~pq.ConnStatus.OK` and `~pq.ConnStatus.BAD`. A good connection to the
+ database has the status `!OK`. Ordinarily, an `!OK` status will remain
+ so until `Connection.close()`, but a communications failure might
+ result in the status changing to `!BAD` prematurely.
+
.. autoattribute:: transaction_status
+
+ The status can be `~pq.TransactionStatus.IDLE` (currently idle),
+ `~pq.TransactionStatus.ACTIVE` (a command is in progress),
+ `~pq.TransactionStatus.INTRANS` (idle, in a valid transaction block),
+ or `~pq.TransactionStatus.INERROR` (idle, in a failed transaction
+ block). `~pq.TransactionStatus.UNKNOWN` is reported if the connection
+ is bad. `!ACTIVE` is reported only when a query has been sent to the
+ server and not yet completed.
+
.. autoattribute:: server_version
.. automethod:: get_parameters
.. autoattribute:: host
+
+ This can be a host name, an IP address, or a directory path if the
+ connection is via Unix socket. (The path case can be distinguished
+ because it will always be an absolute path, beginning with ``/``.)
+
+ .. autoattribute:: hostaddr
+
.. autoattribute:: port
.. autoattribute:: dbname
.. autoattribute:: user
@property
def host(self) -> str:
- """The host name of the database. See :pq:`PQhost`."""
+ """The server host name of the active connection. See :pq:`PQhost`."""
return self._get_pgconn_attr("host")
@property
def hostaddr(self) -> str:
- """The server ip address of the connection. See :pq:`PQhostaddr`."""
+ """The server IP address of the connection. See :pq:`PQhostaddr`."""
return self._get_pgconn_attr("hostaddr")
@property
def port(self) -> int:
- """The port of the database connection. See :pq:`PQport`."""
+ """The port of the active connection. See :pq:`PQport`."""
return int(self._get_pgconn_attr("port"))
@property
@property
def user(self) -> str:
- """The user of the database connection. See :pq:`PQuser`."""
+ """The user name of the connection. See :pq:`PQuser`."""
return self._get_pgconn_attr("user")
@property
def password(self) -> str:
- """The password of the database connection. See :pq:`PQpass`."""
+ """The password of the connection. See :pq:`PQpass`."""
return self._get_pgconn_attr("password")
@property
def options(self) -> str:
"""
- The options parameter of the database connection. See :pq:`PQoptions`.
+ The command-line options passed in the connection request.
+ See :pq:`PQoptions`.
"""
return self._get_pgconn_attr("options")
@property
def status(self) -> pq.ConnStatus:
- """`pq.ConnStatus` enum representing the state of the connection."""
+ """The status of the connection. See :pq:`PQstatus`."""
return pq.ConnStatus(self.pgconn.status)
@property
def transaction_status(self) -> pq.TransactionStatus:
"""
- `pq.TransactionStatus` enum representing the state of the transaction.
+ The current in-transaction status of the server.
+ See :pq:`PQtransactionStatus`.
"""
return pq.TransactionStatus(self.pgconn.transaction_status)
@property
def protocol_version(self) -> int:
- """The frontend/backend protocol currently used."""
+ """
+ The frontend/backend protocol currently used. See :pq:`PQprotocolVersion`.
+ """
return self.pgconn.protocol_version
def _get_pgconn_attr(self, name: str) -> str: