Skip to content

Commit

Permalink
[Issue 2665] Add search path to db connection params (#2836)
Browse files Browse the repository at this point in the history
## Summary
Fixes #2665 

### Time to review: __1 min__

## Changes proposed
> What was added, updated, or removed in this PR.

Added search path to db connection params.

## Context for reviewers
> Testing instructions, background context, more in-depth details of the
implementation, and anything else you'd like to call out or ask
reviewers. Explain how the changes were verified.

This is latest step in a series of attempts to resolve failed db
connections and privileges from /analytics step functions. See ticket
history and comments for details.

## Additional information
> Screenshots, GIF demos, code examples or output to help show the
changes working as expected.
  • Loading branch information
DavidDudas-Intuitial authored Nov 13, 2024
1 parent fec4a09 commit cdc2ad4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions analytics/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion analytics/local.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
ANALYTICS_SLACK_BOT_TOKEN=DO_NOT_SET_HERE
1 change: 1 addition & 0 deletions analytics/src/analytics/integrations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
}


Expand Down

0 comments on commit cdc2ad4

Please sign in to comment.