本文整理汇总了Python中alembic.operations.Operations.drop_table方法的典型用法代码示例。如果您正苦于以下问题:Python Operations.drop_table方法的具体用法?Python Operations.drop_table怎么用?Python Operations.drop_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alembic.operations.Operations
的用法示例。
在下文中一共展示了Operations.drop_table方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recheck_alembic_table
# 需要导入模块: from alembic.operations import Operations [as 别名]
# 或者: from alembic.operations.Operations import drop_table [as 别名]
def recheck_alembic_table(conn):
"""check and update alembic version table.
Should check current alembic version table against conf and rename the
existing table if the two values don't match.
"""
conf_table = getattr(CONF, 'version_table')
conf_table_version = get_table_version(conn, conf_table)
current_table, default_table = get_db_tables(conn)
if current_table[0]:
if current_table[0] != conf_table:
context = alembic_migration.MigrationContext.configure(conn)
op = Operations(context)
if conf_table and not conf_table_version:
# make sure there is not present-but-empty table
# that will prevent us from renaming the current table
op.drop_table(conf_table)
op.rename_table(current_table[0], conf_table)
示例2: declarative_base
# 需要导入模块: from alembic.operations import Operations [as 别名]
# 或者: from alembic.operations.Operations import drop_table [as 别名]
from sqlalchemy.ext.declarative import declarative_base
from alembic.operations import Operations
from alembic.migration import MigrationContext
Base = declarative_base()
engine = sa.create_engine('mysql://root:[email protected]/jpic')
Session = orm.sessionmaker(bind=engine)
session = Session()
conn = engine.connect()
ctx = MigrationContext.configure(conn)
op = Operations(ctx)
for table in ('person_car', 'cars', 'houses', 'persons'):
op.drop_table(table)
class PersonTest(unittest.TestCase):
def test_000_create_table(self):
self.__class__.Person = type('Person', (Base,), {'__tablename__': 'persons',
'id': sa.Column(sa.Integer, primary_key=True)})
self.__class__.Car = type('Car', (Base,), {'__tablename__': 'cars',
'id': sa.Column(sa.Integer, primary_key=True)})
self.__class__.House = type('House', (Base,), {'__tablename__': 'houses',
'id': sa.Column(sa.Integer, primary_key=True)})
Base.metadata.create_all(engine)