Skip to content

Postgres

Local/Built-in Scheduler

Engine Adapter Type: postgres

Installation

pip install "sqlmesh[postgres]"

Connection options

Option Description Type Required
type Engine type name - must be postgres string Y
host The hostname of the Postgres server string Y
user The username to use for authentication with the Postgres server string Y
password The password to use for authentication with the Postgres server string Y
port The port number of the Postgres server int Y
database The name of the database instance to connect to string Y
keepalives_idle The number of seconds between each keepalive packet sent to the server. int N
connect_timeout The number of seconds to wait for the connection to the server. (Default: 10) int N
role The role to use for authentication with the Postgres server string N
sslmode The security of the connection to the Postgres server string N

Airflow Scheduler

Engine Name: postgres

The SQLMesh Postgres Operator is similar to the PostgresOperator, and relies on the same PostgresHook implementation.

To enable support for this operator, the Airflow Postgres provider package should be installed on the target Airflow cluster along with SQLMesh with the Postgres extra:

pip install "apache-airflow-providers-postgres"
pip install "sqlmesh[postgres]"

The operator requires an Airflow connection to determine the target Postgres account. Refer to Postgres connection for more details.

By default, the connection ID is set to postgres_default, but can be overridden using the engine_operator_args parameter to the SQLMeshAirflow instance as in the example below:

1
2
3
4
5
6
7
sqlmesh_airflow = SQLMeshAirflow(
    "postgres",
    default_catalog="<database name>",
    engine_operator_args={
        "postgres_conn_id": "<Connection ID>"
    },
)