本文整理匯總了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)