I’ve been having trouble with database configuration using Alembic considering I am using environment variables and my password has a special character.
Is there an easier way to do it other than encoding the password then replacing every % sign with %%
I have tried encoding the password to “remove” the special character then replacing every % from the encoded password with %% as in the code below:
db_password = urllib.parse.quote_plus(f”{settings.db_password}”). replace(“%”,”%%”)
After which I pass the password into the set_main_option function for the sqlachemy url as in the code below:
config.set_main_option(“sqlachemy.url”, f’postgres+psycopg2://{settings.db_user}:{db_password}@{settings.db_host}:{settings.db_port}/{settings.db_name}’)