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


Python api.make_update_script_for_model函数代码示例

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


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

示例1: _generateMigrationScript

def _generateMigrationScript(dryrun):
    newVersion = findMaxAvailableVersion() + 1
    migration = SQLALCHEMY_MIGRATE_REPO + \
                '/versions/%03d_migration.py' % (newVersion)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI,
                                 SQLALCHEMY_MIGRATE_REPO)

    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI,
                                              SQLALCHEMY_MIGRATE_REPO,
                                              tmp_module.meta,
                                              db.metadata)
    if not dryrun:
        open(migration, "wt").write(script)
        api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
        print 'New migration saved as ' + migration
        print 'Current database version: ' + \
              str(api.db_version(SQLALCHEMY_DATABASE_URI,
                                 SQLALCHEMY_MIGRATE_REPO))
    else:
        print 'Dryrun:'
        print '\nNew migration will be as ' + migration
        print '\nNew migration script will be:\n"\n%s"' % str(script)
        print '\nNew database version will be: ' + str(newVersion)
开发者ID:FYJen,项目名称:website,代码行数:25,代码来源:db_script.py

示例2: migratedb

def migratedb():
    """ Updates the database and SQLAlchemy-migrate repository
        to a new version containing all of the tables defined
        in the SQLAlchemy data models.
    """

    # Obtain Current Verison
    ver = api.db_version(app.config['SQLALCHEMY_DATABASE_URI'],
                         app.config['SQLALCHEMY_MIGRATE_REPO'])

    # Create Migration Script To Apply Model Changes
    mgr = app.config['SQLALCHEMY_MIGRATE_REPO'] +\
        ('/versions/%03d_migration.py' % (ver+1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(app.config['SQLALCHEMY_DATABASE_URI'],
                                 app.config['SQLALCHEMY_MIGRATE_REPO'])
    exec(old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(
        app.config['SQLALCHEMY_DATABASE_URI'],
        app.config['SQLALCHEMY_MIGRATE_REPO'],
        tmp_module.meta, db.metadata)
    open(mgr, "wt").write(script)

    # Update Database With Migration Script
    api.upgrade(app.config['SQLALCHEMY_DATABASE_URI'],
                app.config['SQLALCHEMY_MIGRATE_REPO'])

    # Obtain & Display Current Version & Migration
    ver = api.db_version(app.config['SQLALCHEMY_DATABASE_URI'],
                         app.config['SQLALCHEMY_MIGRATE_REPO'])
    print('New migration saved as: ' + mgr)
    print('Current databse version: ' + str(ver))
开发者ID:ikinsella,项目名称:squall,代码行数:32,代码来源:manage.py

示例3: migrate

def migrate(args):
    """
    Create DB migrations for current version
    """

    # Get the configruation
    config = get_config()
    DB_URI = config.DATABASE_URI
    M_REPO = config.MIGRATIONS

    v = api.db_version(DB_URI, M_REPO)
    m = os.path.join(M_REPO, 'versions', '%03d_migration.py' % (v + 1))

    tmpmod = imp.new_module('old_model')
    oldmod = api.create_model(DB_URI, M_REPO)
    exec(oldmod, tmpmod.__dict__)

    script = api.make_update_script_for_model(
        DB_URI, M_REPO, tmpmod.meta, elmr.db.metadata
    )

    with open(m, 'wt') as f:
        f.write(script)

    v = api.db_version(DB_URI, M_REPO)

    return "New migration saved as %s\nCurrent database version: %d" % (m, v)
开发者ID:eleventhend,项目名称:jobs-report,代码行数:27,代码来源:elmr-admin.py

示例4: __init__

 def __init__(self,database):
     migration=SQLALCHEMY_MIGRATE_CONT+"/versions/%03d_migration.py" % (api.db_version(SQLALCHEMY_DATABASE_URI,SQLALCHEMY_MIGRATE_CONT)+1)
     tmp_module=imp.new_module("old_model")
     old_model=api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_CONT)
     exec old_model in tmp_module.__dict__
     script=api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_CONT, tmp_module.meta, database.metadata)
     open(migration,"wt").write(script)
     a=api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_CONT)
开发者ID:Persipaani,项目名称:blogi,代码行数:8,代码来源:database_migrate.py

示例5: migrate_database

def migrate_database():
    migration = c.SQLALCHEMY_MIGRATE_REPO + '/versions/%03d_migration.py' % (api.db_version(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO)
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO)
    print 'New migration saved as ' + migration
    print 'Current database version: ' + str(api.db_version(c.SQLALCHEMY_DATABASE_URI, c.SQLALCHEMY_MIGRATE_REPO))
开发者ID:jharkins,项目名称:webapp-template,代码行数:10,代码来源:db_manage.py

示例6: migrate

def migrate():
    from migrate.versioning import api
    migration = SQLALCHEMY_MIGRATE_REPO + '/versions/%03d_migration.py' % (api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    print u'Миграция успешна: ' + migration
    print u'Версия базы данных: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO))
开发者ID:dpsmartws,项目名称:PROM.ua-Test-work,代码行数:11,代码来源:run.py

示例7: migrate_db

def migrate_db():
    migration = os.path.join(MG_REPO, 'versions', '%03d_migration.py' % (api.db_version(DB_URI, MG_REPO) + 1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(DB_URI, MG_REPO)
    exec(old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(DB_URI, MG_REPO, tmp_module.meta, db.metadata)
    # ?
    open(migration, 'wt').write(script)
    api.upgrade(DB_URI, MG_REPO)
    print('New migration saved as ' + migration)
    print('Current database version: ' + str(api.db_version(DB_URI, MG_REPO)))
开发者ID:Andor-Z,项目名称:My-Learning-Note,代码行数:11,代码来源:db_migrate.py

示例8: migratedb

def migratedb():
    """Creates a migration file and version."""
    migration = app.config.get('SQLALCHEMY_MIGRATE_REPO') + '/versions/%03d_migration.py' % (api.db_version(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO')) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'))
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'), tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'))
    print 'New migration saved as ' + migration
    print 'Current database version: ' + str(api.db_version(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO')))
开发者ID:vierja,项目名称:logprecios,代码行数:11,代码来源:manage.py

示例9: migrate_db

def migrate_db():
    import imp
    v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    migration = SQLALCHEMY_MIGRATE_REPO + ('/versions/%03d_migration.py' % (v+1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    exec(old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, Base.metadata)
    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
开发者ID:TemosEngenharia,项目名称:RPI-IO,代码行数:11,代码来源:models.py

示例10: migrate_db

def migrate_db():
    v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    migration = SQLALCHEMY_MIGRATE_REPO + ('/versions/%03d_migration.py' % (v + 1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    exec(old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    print('New migration saved as ' + migration)
    print('Current database version: ' + str(v))
开发者ID:rsp-internet-services,项目名称:Batex-os,代码行数:12,代码来源:manage.py

示例11: db_migrate

def db_migrate():
    import imp
    migration = SQLALCHEMY_MIGRATE_REPO + '/versions/%03d_migration.py' % (api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    #exec old_model in tmp_module.__dict__ # python2
    exec (old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    print ('New migration saved as ' + migration)
    print ('Current database version: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)))
开发者ID:ricardobergamo,项目名称:flask-base-bootstrap,代码行数:12,代码来源:manager.py

示例12: db_migrate

def db_migrate():
    import imp
    import re
    from migrate.versioning import api
    from wpcgi.db import db
    migration = SQLALCHEMY_MIGRATE_REPO + '/versions/%04d_migration.py' % (api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
    script = re.sub('INTEGER\(.*?\)', 'INTEGER', script)
    open(migration, "wt").write(script)
    print 'New migration saved as ' + migration
开发者ID:nullzero,项目名称:wpcgi,代码行数:13,代码来源:runner.py

示例13: migrate

def migrate():
    migration = SQLALCHEMY_MIGRATE_REPO + "/versions/%03d_migration.py" % (
        api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1
    )
    tmp_module = imp.new_module("old_model")
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(
        SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata
    )
    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    print "New migration saved as " + migration
    print "Current database version: " + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO))
开发者ID:pace-noge,项目名称:flask-base,代码行数:14,代码来源:db_tools.py

示例14: db_migrate

def db_migrate():
    # This is used for database migration. Newly created database should go through this as well.
    migration = SQLALCHEMY_MIGRATE_REPO + '/versions/%03d_migration.py' % (api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1)
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)

    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)

    open(migration, "wt").write(script)
    api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)

    print 'New migration saved as ' + migration
    print 'Current database version: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)) + '\n'
开发者ID:widoyo,项目名称:EmeraldBox,代码行数:14,代码来源:box.py

示例15: db_migrate

	def db_migrate(self):
		print "DataBase Migrate"
		import imp
		from migrate.versioning import api
		from fpost.app import db
		from fpost.config import SQLALCHEMY_DATABASE_URI
		from fpost.config import SQLALCHEMY_MIGRATE_REPO
		migration = SQLALCHEMY_MIGRATE_REPO + '/versions/%03d_migration.py' % (api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) + 1)
		tmp_module = imp.new_module('old_model')
		old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
		exec old_model in tmp_module.__dict__
		script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
		open(migration, "wt").write(script)
		api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
		print 'New migration saved as ' + migration
		print 'Current database version: ' + str(api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO))
开发者ID:gnpkrish,项目名称:flask_backbone,代码行数:16,代码来源:db.py


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