Skip to content

wip: sqlite wal#164

Draft
xiez wants to merge 1 commit into
mainfrom
fix.sqlite_wal
Draft

wip: sqlite wal#164
xiez wants to merge 1 commit into
mainfrom
fix.sqlite_wal

Conversation

@xiez
Copy link
Copy Markdown
Contributor

@xiez xiez commented May 9, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request configures SQLite to use Write-Ahead Logging (WAL) mode and sets the synchronous pragma to NORMAL for improved performance. It also introduces a configurable busy timeout for SQLite connections. Feedback includes removing a debug print statement in the settings file to prevent potential sensitive information disclosure and using float values for the timeout setting to allow for more granular control.

Comment on lines +93 to +94
DATABASES = {'default': default_db_config}
print(DATABASES)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The print(DATABASES) statement should be removed. Printing the database configuration to standard output can leak sensitive information, such as database credentials (username/password) or internal file paths, into application logs. This is especially risky if the environment is ever switched to a production-grade database like PostgreSQL via environment variables.

Suggested change
DATABASES = {'default': default_db_config}
print(DATABASES)
DATABASES = {'default': default_db_config}


if default_db_config.get('ENGINE') == 'django.db.backends.sqlite3':
default_db_config.setdefault('OPTIONS', {})
default_db_config['OPTIONS']['timeout'] = int(os.environ.get('SQLITE_BUSY_TIMEOUT', 20))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using float() instead of int() for the timeout and using setdefault to avoid overwriting values potentially provided in the database URL. SQLite's timeout parameter (passed to sqlite3.connect) supports fractional seconds, and using float provides more flexibility for fine-tuning the busy timeout.

Suggested change
default_db_config['OPTIONS']['timeout'] = int(os.environ.get('SQLITE_BUSY_TIMEOUT', 20))
default_db_config['OPTIONS'].setdefault('timeout', float(os.environ.get('SQLITE_BUSY_TIMEOUT', 20)))

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.

1 participant