Fix handling of passwords with % in the SQLALCHEMY_DATABASE_URI

Fix Flask-Migrate ValueError from occurring when a password has '%'
characters in it when specified via SQLALCHEMY_DATABASE_URI.
This commit is contained in:
Will Rouesnel 2022-11-04 11:59:59 +11:00
parent f6289d140c
commit 25ebbf132c
No known key found for this signature in database
GPG Key ID: 72DC65802A1091C5

View File

@ -19,7 +19,7 @@ logger = logging.getLogger('alembic.env')
# target_metadata = mymodel.Base.metadata
from flask import current_app
config.set_main_option('sqlalchemy.url',
current_app.config.get('SQLALCHEMY_DATABASE_URI'))
current_app.config.get('SQLALCHEMY_DATABASE_URI').replace("%","%%"))
target_metadata = current_app.extensions['migrate'].db.metadata
# other values from the config, defined by the needs of env.py,