本文整理汇总了Python中alembic.autogenerate.compare_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python autogenerate.compare_metadata方法的具体用法?Python autogenerate.compare_metadata怎么用?Python autogenerate.compare_metadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alembic.autogenerate
的用法示例。
在下文中一共展示了autogenerate.compare_metadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: produce_migrations
# 需要导入模块: from alembic import autogenerate [as 别名]
# 或者: from alembic.autogenerate import compare_metadata [as 别名]
def produce_migrations(context, metadata):
"""Produce a :class:`.MigrationScript` structure based on schema
comparison.
This function does essentially what :func:`.compare_metadata` does,
but then runs the resulting list of diffs to produce the full
:class:`.MigrationScript` object. For an example of what this looks like,
see the example in :ref:`customizing_revision`.
.. versionadded:: 0.8.0
.. seealso::
:func:`.compare_metadata` - returns more fundamental "diff"
data from comparing a schema.
"""
autogen_context = AutogenContext(context, metadata=metadata)
migration_script = ops.MigrationScript(
rev_id=None,
upgrade_ops=ops.UpgradeOps([]),
downgrade_ops=ops.DowngradeOps([]),
)
compare._populate_migration_script(autogen_context, migration_script)
return migration_script
示例2: diff_db
# 需要导入模块: from alembic import autogenerate [as 别名]
# 或者: from alembic.autogenerate import compare_metadata [as 别名]
def diff_db(self):
return compare_metadata(MigrationContext.configure(Session.connection()), metadata)