patroni.psycopg module

Abstraction layer for psycopg module.

This module is able to handle both pyscopg2 and psycopg, and it exposes a common interface for both. psycopg2 takes precedence. psycopg will only be used if psycopg2 is either absent or older than 2.5.4.

_exception _patroni.psycopg.DatabaseError

Bases: Error + Error related to the database engine.

_exception _patroni.psycopg.Error

Bases: Exception + Base class for error exceptions. +

__init\\__(*args, **kwargs)

+

cursor

The cursor that raised the exception, if available, else None +

diag

A Diagnostics object to get further information about the error +

pgcode

The error code returned by the backend, if available, else None +

pgerror

The error message returned by the backend, if available, else None

_exception _patroni.psycopg.OperationalError

Bases: DatabaseError + Error related to database operation (disconnect, memory allocation etc).

_exception _patroni.psycopg.ProgrammingError

Bases: DatabaseError + Error related to database programming (SQL error, table not found etc).

patroni.psycopg.connect(*args: Any, **kwargs: Any) → connection | Connection[Any] View on GitHub

Get a connection to the database. + Note

The connection will have `+autocommit+` enabled.
It also enforces `+search_path=pg_catalog+` for non-replication connections to mitigate security issues as Patroni relies on superuser connections.
+
Parameters:;;
Returns:;;
  a connection to the database. Can be either a `+psycopg.Connection+` if using `+psycopg+`, or a `+psycopg2.extensions.connection+` if using `+psycopg2+`.
patroni.psycopg.quote_ident(value: Any, conn: cursor | connection | Connection[Any] | None = None) → str View on GitHub

Quote value as a SQL identifier. +

Parameters:
Returns:

value quoted as a SQL identifier.

patroni.psycopg.quote_literal(value: Any, conn: Any | None = None) → str View on GitHub

Quote value as a SQL literal. + Note

_value_ is quoted through `+psycopg2+` adapters.
+
Parameters:;;
Returns:;;
  _value_ quoted as a SQL literal.

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

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

Read the Docs v: latest

+ Builds