Skip to content

Postgres State

State manager using postgres database

PostgresState

Bases: State

🗄️ PostgresState: A state manager that stores state in a PostgreSQL database.

This manager provides a persistent storage solution using a PostgreSQL database.

Attributes:

Name Type Description
conn psycopg2.extensions.connection

The PostgreSQL connection.

table str

The table to use for storing state data.

__init__(task_id, host, port, user, password, database, table='geniusrise_state')

Initialize a new PostgreSQL state manager.

Parameters:

Name Type Description Default
task_id str

The identifier for the task.

required
host str

The host of the PostgreSQL server.

required
port int

The port of the PostgreSQL server.

required
user str

The user to connect as.

required
password str

The user's password.

required
database str

The database to connect to.

required
table str

The table to use. Defaults to "geniusrise_state".

'geniusrise_state'

get(task_id, key)

Get the state associated with a task and key.

Parameters:

Name Type Description Default
task_id str

The task identifier.

required
key str

The key to get the state for.

required

Returns:

Type Description
Optional[Dict]

Optional[Dict]: The state associated with the task and key, or None if not found.

set(task_id, key, value)

Set the state associated with a task and key.

Parameters:

Name Type Description Default
task_id str

The task identifier.

required
key str

The key to set the state for.

required
value Dict

The state to set.

required