当前位置: 首页>>代码示例>>Python>>正文


Python alembic.command方法代码示例

本文整理汇总了Python中alembic.command方法的典型用法代码示例。如果您正苦于以下问题:Python alembic.command方法的具体用法?Python alembic.command怎么用?Python alembic.command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在alembic的用法示例。


在下文中一共展示了alembic.command方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: attributes

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def attributes(self):
        """A Python dictionary for storage of additional state.


        This is a utility dictionary which can include not just strings but
        engines, connections, schema objects, or anything else.
        Use this to pass objects into an env.py script, such as passing
        a :class:`sqlalchemy.engine.base.Connection` when calling
        commands from :mod:`alembic.command` programmatically.

        .. versionadded:: 0.7.5

        .. seealso::

            :ref:`connection_sharing`

            :paramref:`.Config.attributes`

        """
        return {} 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:22,代码来源:config.py

示例2: main

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def main(self, argv, environ):
        parser = ArgumentParser(
            prog='temboard-migratedb',
            description="temBoard schema migrator.",
            argument_default=UNDEFINED_ARGUMENT,
        )
        define_arguments(parser)
        args = parser.parse_args(argv)
        self.bootstrap(args=args, environ=environ)

        versions = inspect_versions()
        logger.debug(
            "Using Python %s (%s).",
            versions['python'], versions['pythonbin'])
        logger.debug(
            "Using Psycopg2 %s, Alembic %s and SQLAlchemy %s",
            versions['psycopg2'], versions['alembic'], versions['sqlalchemy'],
        )

        command_method = 'command_' + args.command
        try:
            getattr(self, command_method)(args)
        except sqlalchemy.exc.OperationalError as e:
            raise UserError("Failed to query Postgres server: %s." % e) 
开发者ID:dalibo,项目名称:temboard,代码行数:26,代码来源:migratedb.py

示例3: define_arguments

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def define_arguments(parser):
    define_core_arguments(parser)
    parser.add_argument(
        '-V', '--version',
        action=VersionAction,
        help='show version and exit',
    )
    sub = parser.add_subparsers(
        metavar="COMMAND",
        dest="command",
        help="Operation to execute on temBoard database.")
    sub.add_parser(
        "check",
        help='Check schema synchronisation status only.'
    )
    sub.add_parser(
        "stamp",
        help="Mark database as uptodate without migrating.",
    )
    sub.add_parser(
        "upgrade",
        help="Upgrade temBoard database to latest revision.",
    ) 
开发者ID:dalibo,项目名称:temboard,代码行数:25,代码来源:migratedb.py

示例4: setup_schema

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def setup_schema(command, conf, vars):
    """Place any commands to setup depotexample here"""
    # Load the models

    # <websetup.websetup.schema.before.model.import>
    from depotexample import model
    # <websetup.websetup.schema.after.model.import>

    
    # <websetup.websetup.schema.before.metadata.create_all>
    print("Creating tables")
    model.metadata.create_all(bind=config['tg.app_globals'].sa_engine)
    # <websetup.websetup.schema.after.metadata.create_all>
    transaction.commit()
    print('Initializing Migrations')
    import alembic.config, alembic.command
    alembic_cfg = alembic.config.Config()
    alembic_cfg.set_main_option("script_location", "migration")
    alembic_cfg.set_main_option("sqlalchemy.url", config['sqlalchemy.url'])
    alembic.command.stamp(alembic_cfg, "head") 
开发者ID:amol-,项目名称:depot,代码行数:22,代码来源:schema.py

示例5: do_alembic_command

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def do_alembic_command(config, cmd, *args, **kwargs):
    try:
        getattr(alembic_cmd, cmd)(config, *args, **kwargs)
    except alembic_u.CommandError as e:
        alembic_u.err(str(e)) 
开发者ID:openstack,项目名称:octavia,代码行数:7,代码来源:cli.py

示例6: add_alembic_subparser

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def add_alembic_subparser(sub, cmd):
    return sub.add_parser(cmd, help=getattr(alembic_cmd, cmd).__doc__) 
开发者ID:openstack,项目名称:octavia,代码行数:4,代码来源:cli.py

示例7: add_command_parsers

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def add_command_parsers(subparsers):
    for name in ['current', 'history', 'branches']:
        parser = add_alembic_subparser(subparsers, name)
        parser.set_defaults(func=do_alembic_command)

    help_text = (getattr(alembic_cmd, 'branches').__doc__ +
                 ' and validate head file')
    parser = subparsers.add_parser('check_migration', help=help_text)
    parser.set_defaults(func=do_check_migration)

    parser = add_alembic_subparser(subparsers, 'upgrade')
    parser.add_argument('--delta', type=int)
    parser.add_argument('--sql', action='store_true')
    parser.add_argument('revision', nargs='?')
    parser.set_defaults(func=do_upgrade)

    parser = subparsers.add_parser(
        "upgrade_persistence",
        help="Run migrations for persistence backend")
    parser.set_defaults(func=do_persistence_upgrade)

    parser = subparsers.add_parser('downgrade', help="(No longer supported)")
    parser.add_argument('None', nargs='?', help="Downgrade not supported")
    parser.set_defaults(func=no_downgrade)

    parser = add_alembic_subparser(subparsers, 'stamp')
    parser.add_argument('--sql', action='store_true')
    parser.add_argument('revision')
    parser.set_defaults(func=do_stamp)

    parser = add_alembic_subparser(subparsers, 'revision')
    parser.add_argument('-m', '--message')
    parser.add_argument('--autogenerate', action='store_true')
    parser.add_argument('--sql', action='store_true')
    parser.set_defaults(func=do_revision) 
开发者ID:openstack,项目名称:octavia,代码行数:37,代码来源:cli.py

示例8: do_alembic_command

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def do_alembic_command(config, cmd, *args, **kwargs):
    try:
        getattr(alembic_command, cmd)(config, *args, **kwargs)
    except alembic_util.CommandError as e:
        alembic_util.err(str(e)) 
开发者ID:openstack,项目名称:tacker,代码行数:7,代码来源:cli.py

示例9: command_stamp

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def command_stamp(self, args):
        logging.getLogger('alembic').setLevel(logging.WARN)
        alembic_cfg = build_alembic_config(self.config)
        alembic.command.stamp(alembic_cfg, 'head')
        logger.info("Database marked as up to date.") 
开发者ID:dalibo,项目名称:temboard,代码行数:7,代码来源:migratedb.py

示例10: command_upgrade

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def command_upgrade(self, args):
        alembic_cfg = build_alembic_config(self.config)
        alembic.command.upgrade(alembic_cfg, 'head')
        logger.info("Database up to date.") 
开发者ID:dalibo,项目名称:temboard,代码行数:6,代码来源:migratedb.py

示例11: add_alembic_command

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def add_alembic_command(subparsers, name):
    return subparsers.add_parser(
        name, help=getattr(alembic_command, name).__doc__) 
开发者ID:openstack,项目名称:ironic-inspector,代码行数:5,代码来源:dbsync.py

示例12: do_alembic_command

# 需要导入模块: import alembic [as 别名]
# 或者: from alembic import command [as 别名]
def do_alembic_command(config, cmd, *args, **kwargs):
    try:
        getattr(alembic_cmd, cmd)(config, *args, **kwargs)
    except alembic_u.CommandError as e:
        alembic_u.err(six.text_type(e)) 
开发者ID:openstack,项目名称:qinling,代码行数:7,代码来源:cli.py


注:本文中的alembic.command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。