0

Can't make migrations to albemic I try to write this command in cmd but i getting Error

alembic revision --autogenerate -m "User table"

Error

configparser.InterpolationMissingOptionError: Bad value substitution: option 'sqlalchemy.url' in section 'alembic' contains an interpolation key 'db_user' which is not a valid option name. Raw value: 'postgresql://%(DB_USER)s:%(DB_PASS)s@%(DB_HOST)s:5432/%(DB_NAME)s'

albemic.ini

sqlalchemy.url = postgresql://%(DB_USER)s:%(DB_PASS)s@%(DB_HOST)s:5432/%(DB_NAME)s

env.py

config = context.config
section = config.config_ini_section
config.set_section_option(section, "DB_USER", os.getenv("DB_USER"))
config.set_section_option(section, "DB_PASS", os.getenv("DB_PASS"))
config.set_section_option(section, "DB_NAME", os.getenv("DB_NAME"))
config.set_section_option(section, "DB_HOST", os.getenv("DB_HOST"))
fileConfig(config.config_file_name)
target_metadata = [users.meta]
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • Hi, when you watch the logs, where (which line) is the configParser error trigered? I mean I guess you are loading the section with config.get_section somewhere right? – leh Sep 29 '22 at 10:16

0 Answers0