PostgreSQL¶
Module pglift.postgresql
exposes the following API to manipulate
a PostgreSQL cluster:
- async pglift.postgresql.status(instance: PostgreSQLInstance) Status ¶
Return the status of an instance.
- Raises:
InstanceNotFound – if
pg_ctl status
command exits with status code 4 (data directory not found).
- async pglift.postgresql.check_status(instance: PostgreSQLInstance, expected: Status) None ¶
Check actual instance status with respected to expected one.
- Raises:
InstanceStateError – in case the actual status is not expected.
- pglift.postgresql.is_ready(instance: ~pglift.models.system.PostgreSQLInstance, *, cmd: ~typing.Annotated[~pglift.system.command.CommandType, ~pglift.deps.Dependency(var=<ContextVar name='Command' default=<module 'pglift.system.cmd' from '/home/docs/checkouts/readthedocs.org/user_builds/pglift/envs/stable/lib/python3.13/site-packages/pglift/system/cmd.py'> at 0x71b3ded8e930>)] = <object object>) bool ¶
Return True if the instance is ready per pg_isready.
- pglift.postgresql.logs(instance: ~pglift.models.system.PostgreSQLInstance, *, timeout: float | None = None, poll_interval: float = 0.1, fs: ~typing.Annotated[~pglift.system.fs.AbstractFS[~pathlib.PurePath] | ~pglift.system.fs.AbstractFS[~pathlib.Path], ~pglift.deps.Dependency(var=<ContextVar name='FileSystem' default=<pglift.system.fs.LocalFS object at 0x71b3dee73b60> at 0x71b3ded8e520>)] = <object object>) Iterator[str] ¶
Return the content of current log file as an iterator.
- async pglift.postgresql.replication_lag(instance: PostgreSQLInstance) Decimal | None ¶
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.