• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.version_control函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中migrate.versioning.api.version_control函数的典型用法代码示例。如果您正苦于以下问题:Python version_control函数的具体用法?Python version_control怎么用?Python version_control使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _setup

def _setup(config):
    # disable delayed execution
    # config['adhocracy.amqp.host'] = None
    # FIXME: still do this with rq instead of rabbitmq
    # NOTE: this is called from tests so it may have side effects

    # Create the tables if they don't already exist
    url = config.get('sqlalchemy.url')
    migrate_repo = os.path.join(os.path.dirname(__file__), 'migration')
    repo_version = migrateapi.version(migrate_repo)

    if config.get('adhocracy.setup.drop', "OH_NOES") == "KILL_EM_ALL":
        meta.data.drop_all(bind=meta.engine)
        meta.engine.execute("DROP TABLE IF EXISTS migrate_version")

    try:
        db_version = migrateapi.db_version(url, migrate_repo)
        if db_version < repo_version:
            migrateapi.upgrade(url, migrate_repo)
        initial_setup = False
    except DatabaseNotControlledError:
        meta.data.create_all(bind=meta.engine)
        migrateapi.version_control(url, migrate_repo, version=repo_version)
        initial_setup = True

    install.setup_entities(config, initial_setup)
开发者ID:whausen,项目名称:part,代码行数:26,代码来源:websetup.py


示例2: db_version_control

def db_version_control(engine, abs_path, version=None):
    """
    Mark a database as under this repository's version control.
    """
    repository = _find_migrate_repo(abs_path)
    versioning_api.version_control(engine, repository, version)
    return version
开发者ID:liuliuxiaoge,项目名称:XDRS,代码行数:7,代码来源:migration.py


示例3: create_db

def create_db():
    Base.metadata.create_all(engine)

    if not path.exists(SQLALCHEMY_MIGRATE_REPO):
        api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
    M1A = Module(name=u'M1A', slot=1, gpio=8, io_type='input', rpull=False, status=False, device_id='')
    M1B = Module(name=u'M1B', slot=1, gpio=7, io_type='input', rpull=False, status=False, device_id='')
    M1C = Module(name=u'M1C', slot=1, gpio=11, io_type='input', rpull=False, status=False, device_id='')
    M2A = Module(name=u'M2A', slot=2, gpio=9, io_type='input', rpull=False, status=False, device_id='')
    M2B = Module(name=u'M2B', slot=2, gpio=10, io_type='input', rpull=False, status=False, device_id='')
    M2C = Module(name=u'M2C', slot=2, gpio=5, io_type='input', rpull=False, status=False, device_id='')
    M3A = Module(name=u'M3A', slot=3, gpio=6, io_type='input', rpull=False, status=False, device_id='')
    M3B = Module(name=u'M3B', slot=3, gpio=12, io_type='input', rpull=False, status=False, device_id='')
    M3C = Module(name=u'M3C', slot=3, gpio=13, io_type='input', rpull=False, status=False, device_id='')
    M4A = Module(name=u'M4A', slot=4, gpio=0, io_type='input', rpull=False, status=False, device_id='')
    M4B = Module(name=u'M4B', slot=4, gpio=1, io_type='input', rpull=False, status=False, device_id='')
    M4C = Module(name=u'M4C', slot=4, gpio=16, io_type='input', rpull=False, status=False, device_id='')
    M5A = Module(name=u'M5A', slot=5, gpio=17, io_type='input', rpull=False, status=False, device_id='')
    M5B = Module(name=u'M5B', slot=5, gpio=18, io_type='input', rpull=False, status=False, device_id='')
    M5C = Module(name=u'M5C', slot=5, gpio=19, io_type='input', rpull=False, status=False, device_id='')
    M6A = Module(name=u'M6A', slot=6, gpio=20, io_type='input', rpull=False, status=False, device_id='')
    M6B = Module(name=u'M6B', slot=6, gpio=21, io_type='input', rpull=False, status=False, device_id='')
    M6C = Module(name=u'M6C', slot=6, gpio=22, io_type='input', rpull=False, status=False, device_id='')
    M7A = Module(name=u'M7A', slot=7, gpio=23, io_type='input', rpull=False, status=False, device_id='')
    M7B = Module(name=u'M7B', slot=7, gpio=24, io_type='input', rpull=False, status=False, device_id='')
    M7C = Module(name=u'M7C', slot=7, gpio=25, io_type='input', rpull=False, status=False, device_id='')
    modules = [M1A, M1B, M1C, M2A, M2B, M2C, M3A, M3B, M3C, M4A, M4B, M4C,
               M5A, M5B, M5C, M6A, M6B, M6C, M7A, M7B, M7C]
    for m in modules:
        session.add(m)
    session.commit()
开发者ID:TemosEngenharia,项目名称:RPI-IO,代码行数:34,代码来源:models.py


示例4: db_sync

def db_sync():
    repo_path = os.path.abspath(os.path.dirname(migrate_repo.__file__))
    try:
        versioning_api.upgrade(CONF.database.connection, repo_path)
    except versioning_exceptions.DatabaseNotControlledError:
        versioning_api.version_control(CONF.database.connection, repo_path)
        versioning_api.upgrade(CONF.database.connection, repo_path)
开发者ID:TimurNurlygayanov,项目名称:murano-api,代码行数:7,代码来源:session.py


示例5: setup_db

def setup_db(settings):
    """ We need to create the test sqlite database to run our tests against

    If the db exists, remove it
    We're using the SA-Migrations API to create the db and catch it up to the
    latest migration level for testing

    In theory, we could use this API to do version specific testing as well if
    we needed to.

    If we want to run any tests with a fresh db we can call this function

    """
    from migrate.versioning import api as mig
    sa_url = settings['sqlalchemy.url']
    migrate_repository = 'migrations'

    # we're hackish here since we're going to assume the test db is whatever is
    # after the last slash of the SA url sqlite:///somedb.db
    db_name = sa_url[sa_url.rindex('/') + 1:]
    try:
        os.remove(db_name)
    except:
        pass

    open(db_name, 'w').close()

    mig.version_control(sa_url, migrate_repository)
    mig.upgrade(sa_url, migrate_repository)
开发者ID:briangershon,项目名称:Bookie,代码行数:29,代码来源:__init__.py


示例6: _walk_versions

    def _walk_versions(self, engine=None):
        """Walk through and test the migration scripts

        Determine latest version script from the repo, then
        upgrade from 1 through to the latest, then downgrade from
        the latest back to 1, with no data in the databases. This
        just checks that the schema itself upgrades and downgrades
        successfully.
        """
        # Place the database under version control
        migration_api.version_control(engine, self.REPOSITORY,
                                      self.INIT_VERSION)
        assert_equal(self.INIT_VERSION,
                     migration_api.db_version(engine, self.REPOSITORY))

        LOG.debug('Latest version is %s' % self.REPOSITORY.latest)
        versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)

        # Snake walk from version 1 to the latest, testing the upgrade paths.
        # upgrade -> downgrade -> upgrade
        for version in versions:
            self._migrate_up(engine, version)
            self._migrate_down(engine, version - 1)
            self._migrate_up(engine, version)

        # Now snake walk back down to version 1 from the latest, testing the
        # downgrade paths.
        # downgrade -> upgrade -> downgrade
        for version in reversed(versions):
            self._migrate_down(engine, version - 1)
            self._migrate_up(engine, version)
            self._migrate_down(engine, version - 1)
开发者ID:HoratiusTang,项目名称:trove,代码行数:32,代码来源:migrations.py


示例7: run

	def run(self):
		db.create_all()
		if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
			api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
			api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
		else:
			api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
开发者ID:iepathos,项目名称:flask-microblog,代码行数:7,代码来源:manager.py


示例8: createdb

def createdb():
    """ Creates a database with all of the tables defined in
        the SQLAlchemy models. Creates and initializes an
        SQLAlchemy-migrate repository if none exists.
    """

    # Create New DB Reflecting SQLAlchemy Data Models
    db.create_all(app=app)
    admin = User('admin', '/home/admin', 'password')
    db.session.add(admin)
    db.session.commit()

    # Create SQLAlchemy-migrate Versioning Repository If Absent
    if not os.path.exists(app.config['SQLALCHEMY_MIGRATE_REPO']):
        api.create(app.config['SQLALCHEMY_MIGRATE_REPO'],
                   'database repository')
        api.version_control(app.config['SQLALCHEMY_DATABASE_URI'],
                            app.config['SQLALCHEMY_MIGRATE_REPO'])
        print "SQLAlchemy-migrate Versioning Repository Created in: " +\
            app.config['SQLALCHEMY_MIGRATE_REPO']
    else:
        api.version_control(app.config['SQLALCHEMY_DATABASE_URI'],
                            app.config['SQLALCHEMY_MIGRATE_REPO'],
                            api.version(
                                app.config['SQLALCHEMY_MIGRATE_REPO']))
    print "Database created in: " + app.config['SQLALCHEMY_DATABASE_URI']
开发者ID:ikinsella,项目名称:squall,代码行数:26,代码来源:manage.py


示例9: _memorydb_migrate_db

def _memorydb_migrate_db(**kwargs):
    """
    This is crazy crackheaded, and abusive to sqlalchemy.

    We'll take out dispose so the migrate stuff doesn't kill it,
    and push through the migrate.  This makes a bunch of assumptions
    that are likely stupid, but since this is done on a memory-backed
    db for testing, it's probably okay.

    Just don't run this on a real db.
    """
    def dispose_patch(*args, **kwargs):
        pass

    global engine

    Base.metadata.create_all(bind=engine)
    for table in reversed(Base.metadata.sorted_tables):
        session.execute(table.delete())
        session.commit()

    old_dispose = engine.dispose
    engine.dispose = dispose_patch

    repo_path = repo.Repository(
        os.path.abspath(os.path.dirname(opencenter_repo.__file__)))
    migrate_api.version_control(engine, repo_path)
    migrate_api.upgrade(engine, repo_path)
    engine.dispose = old_dispose
开发者ID:BATYD-Turksat,项目名称:opencenter,代码行数:29,代码来源:database.py


示例10: db_create

def db_create():
    """Create the database"""
    try:
        migrate_api.version_control(url=db_url, repository=db_repo)
        db_upgrade()
    except DatabaseAlreadyControlledError:
        print 'ERROR: Database is already version controlled.'
开发者ID:Ms2ger,项目名称:standup,代码行数:7,代码来源:manage.py


示例11: db_sync

def db_sync(version=None):
    """Place a database under migration control and perform an upgrade."""
    try:
        versioning_api.version_control(
            CFG.db.sql_connection, get_migrate_repo_path())
    except versioning_exceptions.DatabaseAlreadyControlledError, e:
        pass
开发者ID:pperezrubio,项目名称:Tempo,代码行数:7,代码来源:migration.py


示例12: initialize_startup

def initialize_startup():
    """ Force DB tables create, in case no data is already found."""
    is_db_empty = False
    session = SA_SESSIONMAKER()
    inspector = reflection.Inspector.from_engine(session.connection())
    if len(inspector.get_table_names()) < 1:
        LOGGER.debug("Database access exception, maybe DB is empty")
        is_db_empty = True
    session.close()

    if is_db_empty:
        LOGGER.info("Initializing Database")
        if os.path.exists(cfg.DB_VERSIONING_REPO):
            shutil.rmtree(cfg.DB_VERSIONING_REPO)
        migratesqlapi.create(cfg.DB_VERSIONING_REPO, os.path.split(cfg.DB_VERSIONING_REPO)[1])
        _update_sql_scripts()
        migratesqlapi.version_control(cfg.DB_URL, cfg.DB_VERSIONING_REPO, version=cfg.DB_CURRENT_VERSION)
        session = SA_SESSIONMAKER()
        model.Base.metadata.create_all(bind=session.connection())
        session.commit()
        session.close()
        LOGGER.info("Database Default Tables created successfully!")
    else:
        _update_sql_scripts()
        migratesqlapi.upgrade(cfg.DB_URL, cfg.DB_VERSIONING_REPO, version=cfg.DB_CURRENT_VERSION)
        LOGGER.info("Database already has some data, will not be re-created!")
    return is_db_empty
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:27,代码来源:model_manager.py


示例13: _init_database

    def _init_database(self, url):
        LOG.debug('Building Engine')
        engine = sqlalchemy.create_engine(url)
        LOG.debug('Initializing database')
        versioning_api.version_control(engine, repository=self.REPOSITORY)

        return engine
开发者ID:mou,项目名称:designate,代码行数:7,代码来源:test_sqlalchemy.py


示例14: __init__

 def __init__(self, file, repository, echoresults):
     
     #for backward compatibelity
     if re.match('^\w+://', file) == None:
         file = 'sqlite:///'+file   
     
     self.version = 2
     self.dbfile = file
     self.repository = repository
     
  
     
     #migrate code
     try:
         dbversion = api.db_version(file, self.repository)
         #print dbversion
     except :
         dbversion = 0
         api.version_control(file, self.repository, dbversion)
     
     if dbversion < self.version:
         api.upgrade(file, self.repository, self.version)
     elif  dbversion > self.version:
         api.downgrade(file, self.repository, self.version)
     
     engine = create_engine(file , echo=False)#edit by hassan : echoresults to True
     
     metadata = Base.metadata
     metadata.create_all(engine)
 
     Session = sessionmaker(engine)
     self.session = Session()            
开发者ID:AhmadHamzeei,项目名称:Amir-Accounting,代码行数:32,代码来源:__init__.py


示例15: create_database

def create_database():
    db.create_all()
    if not os.path.exists(c.SQLALCHEMY_MIGRATE_REPO):
        api.create(c.SQLALCHEMY_MIGRATE_REPO, 'database repository')
        api.version_control(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO, api.version(c.SQLALCHEMY_MIGRATE_REPO))
开发者ID:jharkins,项目名称:webapp-template,代码行数:7,代码来源:db_manage.py


示例16: test_passing_engine

    def test_passing_engine(self):
        repo = self.tmp_repos()
        api.create(repo, 'temp')
        api.script('First Version', repo)
        engine = construct_engine('sqlite:///:memory:')

        api.version_control(engine, repo)
        api.upgrade(engine, repo)
开发者ID:A-Tran,项目名称:Indecisive,代码行数:8,代码来源:test_util.py


示例17: sync

def sync(conf):
    register_conf_opts(conf)
    repo_path = os.path.abspath(os.path.dirname(migrate_repo.__file__))
    try:
        versioning_api.upgrade(conf.sql.connection, repo_path)
    except versioning_exceptions.DatabaseNotControlledError:
        versioning_api.version_control(conf.sql.connection, repo_path)
        versioning_api.upgrade(conf.sql.connection, repo_path)
开发者ID:Sandy4321,项目名称:kulcloud-ost-nbapi,代码行数:8,代码来源:session.py


示例18: _db_version_control

    def _db_version_control(cls):
        try:
            versioning_api.version_control(
                CONF.db.sql_connection, cls._get_repo_path())
        except migrate.exceptions.DatabaseAlreadyControlledError:
            return 'DB is already controlled my migrate'

        return 'Success'
开发者ID:Symantec,项目名称:dao-control,代码行数:8,代码来源:manage.py


示例19: create_db

 def create_db(self):
     self.metadata.create_all(bind=self.metadata.bind)
     # sqlalchemy migrate hack
     from migrate.versioning.api import version_control, version 
     import shakespeare.migration.versions
     v = version(shakespeare.migration.__path__[0])
     log.info( "Setting current version to '%s'" % v )
     version_control(self.metadata.bind.url, shakespeare.migration.__path__[0], v) 
开发者ID:deeban25,项目名称:shakespeare,代码行数:8,代码来源:__init__.py


示例20: init_db

def init_db():
    import models
    Base.metadata.create_all(bind=engine)
    if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
        api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
开发者ID:danthepunman,项目名称:catalog,代码行数:8,代码来源:database.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python schema.changeset函数代码示例发布时间:2022-05-27
下一篇:
Python api.version函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap