Merge pull request #3191 from unic/hotfix/fix-alembic-url-escaping
Fix "ValueError: invalid interpolation syntax in" for special chars in SQLALCHEMY_DATABASE_URI
This commit is contained in:
commit
67c184a97c
|
@ -20,8 +20,9 @@ fileConfig(config.config_file_name)
|
||||||
# target_metadata = mymodel.Base.metadata
|
# target_metadata = mymodel.Base.metadata
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
db_url_escaped = current_app.config.get('SQLALCHEMY_DATABASE_URI').replace('%', '%%')
|
||||||
config.set_main_option(
|
config.set_main_option(
|
||||||
"sqlalchemy.url", current_app.config.get("SQLALCHEMY_DATABASE_URI")
|
"sqlalchemy.url", db_url_escaped
|
||||||
)
|
)
|
||||||
target_metadata = current_app.extensions["migrate"].db.metadata
|
target_metadata = current_app.extensions["migrate"].db.metadata
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue