Skip to content

Environment variable overrides only work with YAML config and not Python config.py #4106

Open
@martinburch

Description

@martinburch

Given a config.py like...

 from sqlmesh.core.config import (
     Config,
     GatewayConfig,
     MSSQLConnectionConfig
 )

 config = Config(
     gateways={
         "local": GatewayConfig(
             connection=MSSQLConnectionConfig(
                 host='localhost',
                 user='sa',
                 password='placeholder',
                 database='db',
             ),
         ),
     },
 )

Attempting to override the password using

export SQLMESH__GATEWAYS__LOCAL__CONNECTION__PASSWORD=real_pw

as shown in https://sqlmesh.readthedocs.io/en/stable/guides/configuration/?h=override#overrides

fails with the error

Error: Missing connection type.

when running a command like sqlmesh --gateway local info

Exporting the whole set of environment variables for the local gateway connection, including SQLMESH__GATEWAYS__LOCAL__CONNECTION__TYPE allows the sqlmesh CLI to run as expected.

When the same config is given as config.yaml instead...

gateways:
  local:
    connection:
      type: mssql
      host: localhost
      user: sa
      password: placeholder
      database: db

...the override works as expected with only the single environment variable SQLMESH__GATEWAYS__LOCAL__CONNECTION__PASSWORD set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions