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