From: Bryce Lohr Date: Thu, 26 Apr 2012 02:12:34 +0000 (-0400) Subject: Updated multidb template's env.py to be closer to generic's. Fixed invalid reference... X-Git-Tag: rel_0_4_0~8^2^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fa2dd94dd73846ee57b9a2ca93e68347a0e0df7;p=thirdparty%2Fsqlalchemy%2Falembic.git Updated multidb template's env.py to be closer to generic's. Fixed invalid reference to options, fixed SQL comment to be MySQL-safe --- diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py index 88122948..e0ebbc12 100644 --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@ -1,17 +1,24 @@ -USE_TWOPHASE = False - +from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool +from logging.config import fileConfig import re import sys -import logging -logging.fileConfig(options.config_file) +USE_TWOPHASE = False + +# 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) # gather section names referring to different # databases. These are named "engine1", "engine2" # in the sample .ini file. -db_names = options.get_main_option('databases') +db_names = config.get_main_option('databases') # add your model's MetaData objects here # for 'autogenerate' support. These must be set @@ -26,6 +33,11 @@ db_names = options.get_main_option('databases') #} target_metadata = {} +# other values from the config, defined by the needs of env.py, +# can be acquired: +# my_important_option = config.get_main_option("my_important_option") +# ... etc. + def run_migrations_offline(): """Run migrations in 'offline' mode. @@ -93,7 +105,7 @@ def run_migrations_online(): downgrade_token="%s_downgrades", target_metadata=target_metadata.get(name) ) - context.execute("--running migrations for engine %s" % name) + context.execute("-- running migrations for engine %s" % name) context.run_migrations(engine=name) if USE_TWOPHASE: