patroni.postgresql.connection module

_class _patroni.postgresql.connection.ConnectionPool View on GitHub

Bases: object + Helper class to manage named connections from Patroni to PostgreSQL. + The instance keeps named NamedConnection objects and parameters that must be used for new connections. +

__init\\__() → None View on GitHub

Create an instance of ConnectionPool class. +

close() → None View on GitHub

Close all named connections from Patroni to PostgreSQL registered in the pool. +

property _conn_kwargs: Dict[ str, Any]_

Connection parameters that must be used for new psycopg connections. +

get(name: str, kwargs_override: Dict[ str, Any] | None = None) → NamedConnection View on GitHub

Get a new named NamedConnection object from the pool. + Note

Creates a new link:#patroni.postgresql.connection.NamedConnection[`+NamedConnection+`] object if it doesn’t yet exist in the pool.
+
Parameters:::
Returns:::
  link:#patroni.postgresql.connection.NamedConnection[`+NamedConnection+`] object.
class _patroni.postgresql.connection.NamedConnection(_pool: ConnectionPool, name: str, kwargs_override: Dict[ str, Any] | None) View on GitHub

Bases: object + Helper class to manage psycopg connections from Patroni to PostgreSQL. +

Variables:

server_version – PostgreSQL version in integer format where we are connected to. +

__init\\__(pool: ConnectionPool, name: str, kwargs_override: Dict[ str, Any] | None) → None View on GitHub

Create an instance of NamedConnection class. +

Parameters

+

property \\__conn_kwargs: Dict[ str, Any]_

Connection parameters for this NamedConnection. +

close(silent: bool = False) → bool View on GitHub

Close the psycopg connection to postgres. +

Parameters

silent – whether the method should not write logs.

Returns

True if psycopg connection was closed, False otherwise.`` +

get() → connection | Connection[Any] View on GitHub

Get psycopg/psycopg2 connection object. + Note

  Opens a new connection if necessary.
  +
  Returns:::
    `+psycopg+` or `+psycopg2+` connection object.
+
query(sql: str, *params: Any) → List[ Tuple[ Any, …​]] View on GitHub

Execute a query with parameters and optionally returns a response. +

Parameters
Returns

a query response as a list of tuples if there is any.

Raises

Error if had issues while executing sql.
PostgresConnectionException: if had issues while connecting to the database. +

server_version_: int_
patroni.postgresql.connection.get_connection_cursor(**kwargs: Any) → Iterator[cursor | Cursor[Any]] View on GitHub

Previous Next


© Copyright 2015 Compose, Zalando SE. Revision 9d231aee.

Built with Sphinx using a theme provided by Read the Docs.

Read the Docs v: latest

+ Builds