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

Python api.make_update_script_for_model函数代码示例

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

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: migrateDB

def migrateDB():
    repo = app.config['SQLALCHEMY_MIGRATE_REPO']
    uri = app.config['SQLALCHEMY_DATABASE_URI']

    v = api.db_version(uri, repo)
    migration = repo + ('/versions/%03d_migration.py' % (v+1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(uri, repo)
    exec(old_model, tmp_module.__dict__)
    script = api.make_update_script_for_model(uri, repo, 
                                    tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(uri, repo)
    v = api.db_version(uri, repo)
    print('New migration saved as ' + migration)
    print('Current database version: ' + str(v))
开发者ID:nosarthur,项目名称:ckc00,代码行数:16,代码来源:manage.py


示例17: migrate_db

def migrate_db(db_uri, migrate_repo):
    v = api.db_version(db_uri, migrate_repo)
    migration = migrate_repo + ('/versions/%03d_migration.py' % (v+1))
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(db_uri, migrate_repo)

    exec(old_model, tmp_module.__dict__)

    script = api.make_update_script_for_model(db_uri, migrate_repo, tmp_module.meta, db.metadata)

    open(migration, "wt").write(script)

    api.upgrade(db_uri, migrate_repo)

    v = api.db_version(db_uri, migrate_repo)
    print('New migration saved as ' + migration)
    print('Current database version: ' + str(v))
开发者ID:danrr,项目名称:SELP,代码行数:17,代码来源:db_migrate.py


示例18: migrate

def migrate():
    """Compare the database against the app models and make a migration
    and upgrade to that version"""

    version = api.db_version(uri, repo) + 1
    migration = repo + '/versions/%03d_migration.py' % version
    tmp_module = imp.new_module('old_model')
    old_model = api.create_model(uri, repo)
    exec old_model in tmp_module.__dict__
    script = api.make_update_script_for_model(uri,
                                              repo,
                                              tmp_module.meta, db.metadata)
    open(migration, "wt").write(script)
    api.upgrade(uri, repo)

    print 'New migration saved as ' + migration
    show_version()
开发者ID:xavitorne,项目名称:microweb,代码行数:17,代码来源:mwdb.py


示例19: _create_migration_script

 def _create_migration_script(self, migration_name, oldmodel, newmodel,
                                 stdout=False, quiet=False):
     '''Generate migration script'''
     version = self._get_db_version() + 1
     migration = '{0}/versions/{1:03}_{2}.py'.format(
         self.sqlalchemy_migration_path, version, migration_name)
     script = api.make_update_script_for_model(self.sqlalchemy_database_uri,
         self.sqlalchemy_migration_path, oldmodel, newmodel)
     header = '# __VERSION__: {0}\n'.format(version)
     script = header + script
     if stdout:
         print(script)
     else:
         with open(migration, 'wt') as f:
             f.write(script)
         if not quiet:
             print('New migration saved as {0}'.format(migration))
             print('To apply migration, run: "manage.py dbmigrate migrate"')
开发者ID:akostyuk,项目名称:flask-dbmigrate,代码行数:18,代码来源:flask_dbmigrate.py


示例20: migrate_db

def migrate_db():
    import imp
    from migrate.versioning import api
    from database.model import db
    
    print("Migrating the database...")
    v = api.db_version(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'))
    migration = app.config.get('SQLALCHEMY_MIGRATE_REPO') + ('/versions/%03d_migration.py' % (v+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, 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'))
    v = api.db_version(app.config.get('SQLALCHEMY_DATABASE_URI'), app.config.get('SQLALCHEMY_MIGRATE_REPO'))
    print("New migration saved as " + migration)
    print("Current database version: " + str(v))
开发者ID:juusokorhonen,项目名称:doifetcher,代码行数:20,代码来源:manage.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python api.upgrade函数代码示例发布时间:2022-05-27
下一篇:
Python api.downgrade函数代码示例发布时间: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