本文整理汇总了Python中test.lib.schema.Table.exists方法的典型用法代码示例。如果您正苦于以下问题:Python Table.exists方法的具体用法?Python Table.exists怎么用?Python Table.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.lib.schema.Table
的用法示例。
在下文中一共展示了Table.exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_drop_bound
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import exists [as 别名]
def test_create_drop_bound(self):
for meta in (MetaData,ThreadLocalMetaData):
for bind in (
testing.db,
testing.db.connect()
):
metadata = meta()
table = Table('test_table', metadata,
Column('foo', Integer))
metadata.bind = bind
assert metadata.bind is table.bind is bind
metadata.create_all()
assert table.exists()
metadata.drop_all()
table.create()
table.drop()
assert not table.exists()
metadata = meta()
table = Table('test_table', metadata,
Column('foo', Integer))
metadata.bind = bind
assert metadata.bind is table.bind is bind
metadata.create_all()
assert table.exists()
metadata.drop_all()
table.create()
table.drop()
assert not table.exists()
if isinstance(bind, engine.Connection):
bind.close()
示例2: test_create_drop_explicit
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import exists [as 别名]
def test_create_drop_explicit(self):
metadata = MetaData()
table = Table('test_table', metadata,
Column('foo', Integer))
for bind in (
testing.db,
testing.db.connect()
):
for args in [
([], {'bind':bind}),
([bind], {})
]:
metadata.create_all(*args[0], **args[1])
assert table.exists(*args[0], **args[1])
metadata.drop_all(*args[0], **args[1])
table.create(*args[0], **args[1])
table.drop(*args[0], **args[1])
assert not table.exists(*args[0], **args[1])
示例3: test_create_drop_constructor_bound
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import exists [as 别名]
def test_create_drop_constructor_bound(self):
for bind in (
testing.db,
testing.db.connect()
):
try:
for args in (
([bind], {}),
([], {'bind':bind}),
):
metadata = MetaData(*args[0], **args[1])
table = Table('test_table', metadata,
Column('foo', Integer))
assert metadata.bind is table.bind is bind
metadata.create_all()
assert table.exists()
metadata.drop_all()
table.create()
table.drop()
assert not table.exists()
finally:
if isinstance(bind, engine.Connection):
bind.close()