- class patroni.postgresql.connection. ConnectionPool View on GitHub
-
Bases:
objectHelper class to manage named connections from Patroni to PostgreSQL.
The instance keeps named
NamedConnectionobjects and parameters that must be used for new connections.- __init__ ( ) None View on GitHub
-
Create an instance of
ConnectionPoolclass.
- close ( ) None View on GitHub
-
Close all named connections from Patroni to PostgreSQL registered in the pool.
- property conn_kwargs : Dict [ str , Any ] View on GitHub
-
Connection parameters that must be used for new
psycopgconnections.
- get ( name : str , kwargs_override : Dict [ str , Any ] | None = None ) NamedConnection View on GitHub
-
Get a new named
NamedConnectionobject from the pool.Note
Creates a new
NamedConnectionobject if it doesn’t yet exist in the pool.- Parameters :
-
-
name – name of the connection.
-
kwargs_override –
dictobject with connection parameters that should be different from default values provided byconn_kwargs.
-
- Returns :
-
NamedConnectionobject.
- class patroni.postgresql.connection. NamedConnection ( pool : ConnectionPool , name : str , kwargs_override : Dict [ str , Any ] | None ) View on GitHub
-
Bases:
objectHelper class to manage
psycopgconnections 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
NamedConnectionclass.- Parameters :
-
-
pool – reference to a
ConnectionPoolobject. -
name – name of the connection.
-
kwargs_override –
dictobject with connection parameters that should be different from default values provided by connection pool .
-
- property _conn_kwargs : Dict [ str , Any ] View on GitHub
-
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 :
-
Trueifpsycopgconnection was closed,Falseotherwise.``
- get ( ) connection | Connection [ Any ] View on GitHub
-
Get
psycopg/psycopg2connection object.Note
Opens a new connection if necessary.
- Returns :
-
psycopgorpsycopg2connection object.
- query ( sql : str , * params : Any ) List [ Tuple [ Any , ... ] ] View on GitHub
-
Execute a query with parameters and optionally returns a response.
- Parameters :
-
-
sql – SQL statement to execute.
-
params – parameters to pass.
-
- Returns :
-
a query response as a list of tuples if there is any.
- Raises :
-
Errorif 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