PostgreSQL¶
Module pglift.postgresql exposes the following API to manipulate
a PostgreSQL cluster:
- async pglift.postgresql.status(instance)¶
Return the status of an instance.
- Raises:
InstanceNotFound – if
pg_ctl statuscommand exits with status code 4 (data directory not found).- Parameters:
instance (PostgreSQLInstance)
- Return type:
Status
- async pglift.postgresql.check_status(instance, expected)¶
Check actual instance status with respected to expected one.
- Raises:
InstanceStateError – in case the actual status is not expected.
- Parameters:
instance (PostgreSQLInstance)
expected (Status)
- Return type:
None
- pglift.postgresql.is_ready(instance, *, cmd=<object object>)¶
Return True if the instance is ready per pg_isready.
- Parameters:
instance (PostgreSQLInstance)
cmd (Annotated[CommandType, Dependency(var=<ContextVar name='Command' default=<module 'pglift.system.cmd' from '/home/docs/checkouts/readthedocs.org/user_builds/pglift/envs/v3.0.0/lib/python3.14/site-packages/pglift/system/cmd.py'> at 0x7ba076673060>)])
- Return type:
- pglift.postgresql.logs(instance, *, timeout=None, poll_interval=0.1, fs=<object object>)¶
Return the content of current log file as an iterator.
- async pglift.postgresql.replication_lag(instance)¶
Return the replication lag of a standby instance.
The instance must be running; if the primary is not running, None is returned.
- Raises:
TypeError – if the instance is not a standby.
- Parameters:
instance (PostgreSQLInstance)
- Return type:
Decimal | None