Skip to content

Instantly share code, notes, and snippets.

@erriapo
Forked from utek/Exclude_tables.md
Created May 14, 2019 20:06
Show Gist options
  • Save erriapo/060b7369ce9685d0f4e2732294f564fb to your computer and use it in GitHub Desktop.
Save erriapo/060b7369ce9685d0f4e2732294f564fb to your computer and use it in GitHub Desktop.

Revisions

  1. @utek utek revised this gist Aug 6, 2013. 1 changed file with 58 additions and 58 deletions.
    116 changes: 58 additions & 58 deletions Exclude_tables.md
    Original file line number Diff line number Diff line change
    @@ -1,65 +1,65 @@
    Add this in your ini file:

    [alembic:exclude]
    tables = spatial_ref_sys
    [alembic:exclude]
    tables = spatial_ref_sys

    In `env.py`:

    def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)
    if tables_ is not None:
    tables = tables_.split(",")
    return tables
    def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)
    if tables_ is not None:
    tables = tables_.split(",")
    return tables

    exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude'))


    def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and name in exclude_tables:
    return False
    else:
    return True

    exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude'))


    def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and name in exclude_tables:
    return False
    else:
    return True

    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=engine.url, include_object=include_object)

    with context.begin_transaction():
    context.run_migrations()


    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.

    """
    if isinstance(engine, Engine):
    connection = engine.connect()
    else:
    raise Exception('Expected engine instance got %s instead' % type(engine))

    context.configure(
    connection=connection,
    target_metadata=target_metadata,
    include_object=include_object
    )

    try:
    with context.begin_transaction():
    context.run_migrations()
    finally:
    connection.close()
    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=engine.url, include_object=include_object)

    with context.begin_transaction():
    context.run_migrations()


    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.

    """
    if isinstance(engine, Engine):
    connection = engine.connect()
    else:
    raise Exception('Expected engine instance got %s instead' % type(engine))

    context.configure(
    connection=connection,
    target_metadata=target_metadata,
    include_object=include_object
    )

    try:
    with context.begin_transaction():
    context.run_migrations()
    finally:
    connection.close()

  2. @utek utek revised this gist Aug 6, 2013. 2 changed files with 65 additions and 21 deletions.
    21 changes: 0 additions & 21 deletions Exclude_tables
    Original file line number Diff line number Diff line change
    @@ -1,21 +0,0 @@
    Add this in your ini file:

    [alembic:exclude]
    tables = spatial_ref_sys

    In `env.py`:
    def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)
    if tables_ is not None:
    tables = tables_.split(",")
    return tables

    exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude'))


    def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and name in exclude_tables:
    return False
    else:
    return True

    65 changes: 65 additions & 0 deletions Exclude_tables.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    Add this in your ini file:

    [alembic:exclude]
    tables = spatial_ref_sys

    In `env.py`:

    def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)
    if tables_ is not None:
    tables = tables_.split(",")
    return tables

    exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude'))


    def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and name in exclude_tables:
    return False
    else:
    return True

    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=engine.url, include_object=include_object)

    with context.begin_transaction():
    context.run_migrations()


    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.

    """
    if isinstance(engine, Engine):
    connection = engine.connect()
    else:
    raise Exception('Expected engine instance got %s instead' % type(engine))

    context.configure(
    connection=connection,
    target_metadata=target_metadata,
    include_object=include_object
    )

    try:
    with context.begin_transaction():
    context.run_migrations()
    finally:
    connection.close()

  3. @utek utek created this gist Aug 6, 2013.
    21 changes: 21 additions & 0 deletions Exclude_tables
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    Add this in your ini file:

    [alembic:exclude]
    tables = spatial_ref_sys

    In `env.py`:
    def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)
    if tables_ is not None:
    tables = tables_.split(",")
    return tables

    exclude_tables = exclude_tables_from_config(config.get_section('alembic:exclude'))


    def include_object(object, name, type_, reflected, compare_to):
    if type_ == "table" and name in exclude_tables:
    return False
    else:
    return True