Я некоторое время искал, как управлять этим для mutli-баз данных
Вот что я сделал. У меня есть две базы данных: журналы и ohlc.
Согласно документу, я настроил перегонный куб как это
alembic init --template multidb
перегонный куб.ini
databases = logs, ohlc
[logs]
sqlalchemy.url = postgresql://botcrypto:botcrypto@localhost/logs
[ohlc]
sqlalchemy.url = postgresql://botcrypto:botcrypto@localhost/ohlc
env.py
[...]
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
# overwrite alembic.ini db urls from the config file
settings_path = os.environ.get('SETTINGS')
if settings_path:
with open(settings_path) as fd:
settings = conf.load(fd, context=os.environ) # loads the config.yml
config.set_section_option("ohlc", "sqlalchemy.url", settings["databases"]["ohlc"])
config.set_section_option("logs", "sqlalchemy.url", settings["databases"]["logs"])
else:
logger.warning('Environment variable SETTINGS missing - use default alembic.ini configuration')
[...]
config.yml
databases:
logs: postgresql://botcrypto:[email protected]:5432/logs
ohlc: postgresql://botcrypto:[email protected]:5432/ohlc
использование
SETTINGS=config.yml alembic upgrade head
Надеюсь, это может помочь!
person
Constantin De La Roche
schedule
13.12.2018
Flask-Migrate
совместим только сFlask-SQLAlchemy
- person dimmg   schedule 18.06.2016sqlachemy.url
вenv.py
? - person dirn   schedule 18.06.2016