diff --git a/analytics/config.py b/analytics/config.py index 9c5cd0bbf..67f620c66 100644 --- a/analytics/config.py +++ b/analytics/config.py @@ -17,6 +17,7 @@ class DBSettings(PydanticBaseEnvConfig): user: str = Field (alias="DB_USER") password: Optional[str] = Field(None, alias="DB_PASSWORD") ssl_mode: str = Field("require", alias="DB_SSL_MODE") + db_schema: str = Field ("app", alias="DB_SCHEMA") slack_bot_token: str = Field(alias="ANALYTICS_SLACK_BOT_TOKEN") reporting_channel_id: str = Field(alias="ANALYTICS_REPORTING_CHANNEL_ID") aws_region: Optional[str] = Field(None, alias="AWS_REGION") diff --git a/analytics/local.env b/analytics/local.env index f8e658c37..eb428ae78 100644 --- a/analytics/local.env +++ b/analytics/local.env @@ -12,6 +12,7 @@ DB_NAME=app DB_USER=app DB_PASSWORD=secret123 DB_SSL_MODE=allow +DB_SCHEMA=public # When an error occurs with a SQL query, # whether or not to hide the parameters which @@ -37,4 +38,4 @@ MB_DB_HOST=grants-analytics-db # Set these in your shell # by doing `export ANALYTICS_REPORTING_CHANNEL_ID=whatever` ANALYTICS_REPORTING_CHANNEL_ID=DO_NOT_SET_HERE -ANALYTICS_SLACK_BOT_TOKEN=DO_NOT_SET_HERE \ No newline at end of file +ANALYTICS_SLACK_BOT_TOKEN=DO_NOT_SET_HERE diff --git a/analytics/src/analytics/integrations/db.py b/analytics/src/analytics/integrations/db.py index 1f907aaa6..cec819829 100644 --- a/analytics/src/analytics/integrations/db.py +++ b/analytics/src/analytics/integrations/db.py @@ -60,6 +60,7 @@ def get_connection_parameters(config: DBSettings) -> dict[str, Any]: "port": config.port, "connect_timeout": 20, "sslmode": config.ssl_mode, + "options": f"-c search_path={config.db_schema}", }