do not use str(url) to stringify a URL for subsequent use

The str(url) function in SQLAlchemy hides the password.
For a URL string that is to be re-used, use
render_as_string(hide_password=False).

Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I5eceac615f142da76019bc4471afb3086bbc7b7e
This commit is contained in:
Takashi Kajinami 2024-05-16 00:17:31 +09:00
parent 20f6add7cf
commit 4fb4256cf7

@ -101,8 +101,9 @@ def db_sync(version=None, engine=None):
# uses *python* interpolation to write the string out ... where "%" is the
# special python interpolation character! Avoid this mismatch by quoting
# all %'s for the set below.
engine_url = str(engine.url).replace('%', '%%')
config.set_main_option('sqlalchemy.url', str(engine_url))
engine_url = engine.url.render_as_string(
hide_password=False).replace('%', '%%')
config.set_main_option('sqlalchemy.url', engine_url)
LOG.info('Applying migration(s)')
_upgrade_alembic(engine, config, version)