Skip to content

Conversation

ZongXR
Copy link

@ZongXR ZongXR commented Aug 6, 2025

fixes #1396

use SQLALCHEMY_ENGINE_OPTIONS as default engine options especially if engine options is not specified in SQLALCHEMY_BINDS.

When engine options is not specified in SQLALCHEMY_BINDS, this engine will lack options with the bind. Which may cause some unexpected errors such as database disconnect error.

SQLALCHEMY_BINDS = {"main": "mysql+pymysql://root:root@localhost:3306/dbname"}
SQLALCHEMY_ENGINE_OPTIONS = {"pool_pre_ping": True}

For example, if someone use Flask-SQLalchemy like this, he will think SQLALCHEMY_ENGINE_OPTIONS will make effect in SQLALCHEMY_BINDS. But that's not the case.

This PR use SQLALCHEMY_ENGINE_OPTIONS as default engine options specifically when engine options is not specified in SQLALCHEMY_BINDS. So the code above will be same as

SQLALCHEMY_BINDS = {
    "main": {
        "url": "mysql+pymysql://root:root@localhost:3306/dbname",
        "pool_pre_ping": True
    }
}

zong.xiangrui added 4 commits August 4, 2025 21:43
use SQLALCHEMY_ENGINE_OPTIONS as default if engine options is not specified in SQLALCHEMY_BINDS
upgrade actions/cache to v4
set SQLALCHEMY_ENGINE_OPTIONS as default engine options
@davidism davidism closed this Aug 6, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

set default engine options while using SQLALCHEMY_BINDS
2 participants