0

I'm using Argparse module to specify which config i should use:

python app.py -c cfg/local.yaml

If I run Flask db upgrade without -c cfg/local.yaml, it uses my prod config, which is set as default:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'qa_start_db' ([Errno 8] nodename nor servname provided, or not known)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)

Next, I want to run alembic migrations via command below, but that's not working:

flask db migrate -c cfg/local.yaml

How cal I tell Flask to understand my optional CLI argument, defined in arguments.py?

import argparse


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config', action='store', required=False)

    return parser.parse_known_args()

Tried to run flask command as usual python, got: Error: No such option: -c

Need to be able to execute Flask db upgrade with my -c option

0 Answers0