Exemplo n.º 1
0
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.
    Calls to context.execute() here emit the given string to the
    script output.
    """
    context.configure(
        url=config.get_main_option('sqlalchemy.url'),
        version_table=config.get_main_option('version_table'),
        literal_binds=True,
    )

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 2
0
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.
    Calls to context.execute() here emit the given string to the
    script output.
    """
    context.configure(
        url=config.get_main_option('sqlalchemy.url'),
        version_table=config.get_main_option('version_table'),
        literal_binds=True,
    )

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 3
0
def run_migrations_offline():
    url = config.get_main_option("sqlalchemy.url")
    context.configure(
        url=url,
        target_metadata=target_metadata,
        literal_binds=True,
        dialect_opts={"paramstyle": "named"},
    )

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 4
0
def run_migrations_offline():
	"""Run migrations in 'offline' mode.

	This configures the context with just a URL
	and not an Engine, though an Engine is acceptable
	here as well.  By skipping the Engine creation
	we don't even need a DBAPI to be available.

	Calls to context.execute() here emit the given string to the
	script output.

	"""
	alembic.context.configure(
		url = config.get_main_option("sqlalchemy.url"), 
		target_metadata = target_metadata, 
		literal_binds = True, 
		process_revision_directives = writer,
		render_as_batch = config.get_main_option('sqlalchemy.url').startswith('sqlite:///'),
		)

	with alembic.context.begin_transaction():
		alembic.context.run_migrations()
Exemplo n.º 5
0
def run_migrations_offline() -> None:
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.

    """
    url = config.get_main_option("sqlalchemy.url")
    configure(url=url)

    with begin_transaction():
        run_migrations()
Exemplo n.º 6
0
Arquivo: env.py Projeto: abrt/faf
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.

    """
    url = config.get_main_option("sqlalchemy.url")
    configure(url=url)

    with begin_transaction():
        run_migrations()
Exemplo n.º 7
0
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.

    """
    url = config.get_main_option('sqlalchemy.url')
    context.configure(url=url, target_metadata=target_metadata, include_schemas=True,
                      version_table_schema='public', include_symbol=_include_symbol, render_item=_render_item)

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 8
0
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.
    """
    url = config.get_main_option('sqlalchemy.url')
    context.configure(url=url, target_metadata=target_metadata, include_schemas=True,
                      include_object=_include_object, render_item=_render_item, version_table=version_table,
                      version_table_schema='public', template_args={'toplevel_code': set()})

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 9
0
def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
    script output.

    """
    url = context.get_x_argument(as_dictionary=True).get('url')
    if not url:
        url = config.get_main_option("sqlalchemy.url")
    context.configure(url=url, target_metadata=target_metadata)

    with context.begin_transaction():
        context.run_migrations()
Exemplo n.º 10
0
def get_url():
    ws_config_path = config.get_main_option("ws_config_path")
    parser = ws.config.ConfigParser(ws_config_path)
    conf = parser.fetch_section("alembic", to_list=False)

    db_dialect = conf.get("db-dialect", "postgresql")
    db_driver = conf.get("db-driver", "psycopg2")
    db_user = conf["db-user"]
    db_password = conf["db-password"]
    db_host = conf.get("db-host", "localhost")
    db_port = conf.get("db-port")
    db_name = conf["db-name"]

    url = sa.engine.url.URL("{}+{}".format(db_dialect, db_driver),
                            username=db_user,
                            password=db_password,
                            host=db_host,
                            port=db_port,
                            database=db_name)
    return url
Exemplo n.º 11
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.
    """
    connectable = sqlalchemy.engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=sqlalchemy.pool.NullPool,
    )

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata,
            version_table=config.get_main_option('version_table'),
        )

        with context.begin_transaction():
            context.run_migrations()
Exemplo n.º 12
0
def get_url():
    ws_config_path = config.get_main_option("ws_config_path")
    f = open(os.path.expanduser(ws_config_path), "r")
    parser = ws.config.ConfigFileParser("site", "alembic")
    conf = parser.parse(f, [])

    db_dialect = conf.get("db-dialect", "postgresql")
    db_driver = conf.get("db-driver", "psycopg2")
    db_user = conf["db-user"]
    db_password = conf["db-password"]
    db_host = conf.get("db-host", "localhost")
    db_port = conf.get("db-port")
    db_name = conf["db-name"]

    url = sa.engine.url.URL("{}+{}".format(db_dialect, db_driver),
                            username=db_user,
                            password=db_password,
                            host=db_host,
                            port=db_port,
                            database=db_name)
    return url
Exemplo n.º 13
0
def get_url():
    ws_config_path = config.get_main_option("ws_config_path")
    f = open(os.path.expanduser(ws_config_path), "r")
    parser = ws.config.ConfigFileParser("site", "alembic")
    conf = parser.parse(f, [])

    db_dialect = conf.get("db-dialect", "postgresql")
    db_driver = conf.get("db-driver", "psycopg2")
    db_user = conf["db-user"]
    db_password = conf["db-password"]
    db_host = conf.get("db-host", "localhost")
    db_port = conf.get("db-port")
    db_name = conf["db-name"]

    url = sa.engine.url.URL("{}+{}".format(db_dialect, db_driver),
                            username=db_user,
                            password=db_password,
                            host=db_host,
                            port=db_port,
                            database=db_name)
    return url
Exemplo n.º 14
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.
    """
    connectable = sqlalchemy.engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=sqlalchemy.pool.NullPool,
    )

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata,
            version_table=config.get_main_option('version_table'),
        )

        with context.begin_transaction():
            context.run_migrations()
Exemplo n.º 15
0
def run_migrations_online():
	"""Run migrations in 'online' mode.

	In this scenario we need to create an Engine
	and associate a connection with the context.

	"""
	connectable = sqlalchemy.engine_from_config(
		config.get_section(config.config_ini_section),
		prefix='sqlalchemy.',
		poolclass=sqlalchemy.pool.NullPool)

	with connectable.connect() as connection:
		alembic.context.configure(
			connection = connection,
			target_metadata = target_metadata,
			process_revision_directives = writer,
			render_as_batch = config.get_main_option('sqlalchemy.url').startswith('sqlite:///'),
		)

		with alembic.context.begin_transaction():
			alembic.context.run_migrations()
Exemplo n.º 16
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import logging.config

from alembic import context
import sqlalchemy

from tuning_box import db

config = context.config
if config.get_main_option('table_prefix') is None:
    config.set_main_option('table_prefix', '')
if config.config_file_name:
    logging.config.fileConfig(config.config_file_name)
target_metadata = db.db.metadata


def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.

    Calls to context.execute() here emit the given string to the
Exemplo n.º 17
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import logging.config

from alembic import context
import sqlalchemy

#from tuning_box import db

config = context.config
if config.get_main_option('table_prefix') is None:
    config.set_main_option('table_prefix', '')
if config.config_file_name:
    logging.config.fileConfig(config.config_file_name)
#target_metadata = db.db.metadata
target_metadata = None


def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.