Skip to content

fix: make SQL echo configurable via env var instead of hardcoded True#373

Open
abhishek-8081 wants to merge 1 commit intofireform-core:mainfrom
abhishek-8081:fix/disable-sql-echo-by-default
Open

fix: make SQL echo configurable via env var instead of hardcoded True#373
abhishek-8081 wants to merge 1 commit intofireform-core:mainfrom
abhishek-8081:fix/disable-sql-echo-by-default

Conversation

@abhishek-8081
Copy link
Copy Markdown

What

Replaced hardcoded echo=True in api/db/database.py with an env var toggle (SQL_DEBUG). SQL echo is now off by default.

Why

echo=True prints every SQL query to stdout on every API request. This was probably left on from debugging but it makes the terminal output really noisy, especially when you're trying to debug something else. It also leaks query details which isn't great.

Changes

# Before
echo=True,

# After
echo=os.getenv("SQL_DEBUG", "false").lower() == "true",

To enable SQL logging when needed, just set the env var:

SQL_DEBUG=true uvicorn api.main:app --reload

Testing

  • Verified SQL output is silent by default (no env var set)
  • Verified SQL_DEBUG=true enables SQL logging as expected
  • No other files depend on this setting

Fixes #372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: echo=True hardcoded in database.py — all SQL queries printed to stdout

1 participant