本文整理汇总了Python中alembic.context.get_x_argument方法的典型用法代码示例。如果您正苦于以下问题:Python context.get_x_argument方法的具体用法?Python context.get_x_argument怎么用?Python context.get_x_argument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alembic.context
的用法示例。
在下文中一共展示了context.get_x_argument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_migrations_offline
# 需要导入模块: from alembic import context [as 别名]
# 或者: from alembic.context import get_x_argument [as 别名]
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
# if a database path was provided, override the one in alembic.ini
database = context.get_x_argument(as_dictionary=True).get('database')
if database:
url = "sqlite:///%s" % database
else:
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True)
with context.begin_transaction():
context.run_migrations()
示例2: get_url
# 需要导入模块: from alembic import context [as 别名]
# 或者: from alembic.context import get_x_argument [as 别名]
def get_url():
"Database URL must be specified on command line with -x url=<DB_URL>"
url = context.get_x_argument(as_dictionary=True).get('url')
return url
示例3: upgrade
# 需要导入模块: from alembic import context [as 别名]
# 或者: from alembic.context import get_x_argument [as 别名]
def upgrade():
schema_upgrades()
# if context.get_x_argument(as_dictionary=True).get('data', None):
# data_upgrades()
示例4: downgrade
# 需要导入模块: from alembic import context [as 别名]
# 或者: from alembic.context import get_x_argument [as 别名]
def downgrade():
# if context.get_x_argument(as_dictionary=True).get('data', None):
# data_downgrades()
schema_downgrades()