is bad. `!ACTIVE` is reported only when a query has been sent to the
server and not yet completed.
- .. autoattribute:: server_version
.. autoattribute:: backend_pid
+ .. autoattribute:: server_version
.. autoattribute:: error_message
.. automethod:: get_parameters
+
+ .. note:: The `dsn` attribute returns the same information in the form
+ as a string.
+
.. autoattribute:: timezone
+
+ .. code:: pycon
+
+ >>> conn.info.timezone
+ zoneinfo.ZoneInfo(key='Europe/Rome')
+
.. autoattribute:: host
This can be a host name, an IP address, or a directory path if the
@property
def host(self) -> str:
- """The server host name of the active connection. 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 active connection. See :pq:`PQport`."""
+ """The port of the active connection. See :pq:`PQport()`."""
return int(self._get_pgconn_attr("port"))
@property
def dbname(self) -> str:
- """The database name of the connection. See :pq:`PQdb`."""
+ """The database name of the connection. See :pq:`PQdb()`."""
return self._get_pgconn_attr("db")
@property
def user(self) -> str:
- """The user name of the 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 connection. See :pq:`PQpass`."""
+ """The password of the connection. See :pq:`PQpass()`."""
return self._get_pgconn_attr("password")
@property
@property
def status(self) -> pq.ConnStatus:
- """The status of the connection. See :pq:`PQstatus`."""
+ """The status of the connection. See :pq:`PQstatus()`."""
return pq.ConnStatus(self.pgconn.status)
@property
def transaction_status(self) -> pq.TransactionStatus:
"""
The current in-transaction status of the server.
- See :pq:`PQtransactionStatus`.
+ See :pq:`PQtransactionStatus()`.
"""
return pq.TransactionStatus(self.pgconn.transaction_status)
The number is formed by converting the major, minor, and revision
numbers into two-decimal-digit numbers and appending them together.
After PostgreSQL 10 the minor version was dropped, so the second group
- of digits is always 00. For example, version 9.3.5 will be returned as
+ of digits is always 00. For example, version 9.3.5 is returned as
90305, version 10.2 as 100002.
"""
return self.pgconn.server_version
def backend_pid(self) -> int:
"""
The process ID (PID) of the backend process handling this connection.
- See :pq:`PQbackendPID`.
+ See :pq:`PQbackendPID()`.
"""
return self.pgconn.backend_pid
@property
def protocol_version(self) -> int:
"""
- The frontend/backend protocol currently used. See :pq:`PQprotocolVersion`.
+ The frontend/backend protocol currently used. See :pq:`PQprotocolVersion()`.
"""
return self.pgconn.protocol_version
def error_message(self) -> str:
"""
The error message most recently generated by an operation on the connection.
- See :pq:`PQerrorMessage`.
+ See :pq:`PQerrorMessage()`.
"""
return self._get_pgconn_attr("error_message")
def pgresult_ptr(self) -> Optional[int]:
"""The pointer to the underlying ``PGresult`` structure, as integer.
- `!None` if the result waas cleared.
+ `!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
def free(self) -> None:
"""
- Free the data structure created by PQgetCancel.
+ Free the data structure created by :pq:`PQgetCancel()`.
Automatically invoked by `!__del__()`.
- See :pq:`PQfreeCancel` for details.
+ See :pq:`PQfreeCancel()` for details.
"""
self.pgcancel_ptr, p = None, self.pgcancel_ptr
if p: