本文整理汇总了Python中test.lib.schema.Table.tometadata方法的典型用法代码示例。如果您正苦于以下问题:Python Table.tometadata方法的具体用法?Python Table.tometadata怎么用?Python Table.tometadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.lib.schema.Table
的用法示例。
在下文中一共展示了Table.tometadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tometadata_strip_schema
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import tometadata [as 别名]
def test_tometadata_strip_schema(self):
meta = MetaData()
table = Table('mytable', meta,
Column('myid', Integer, primary_key=True),
Column('name', String(40), nullable=True),
Column('description', String(30),
CheckConstraint("description='hi'")),
UniqueConstraint('name'),
test_needs_fk=True,
)
table2 = Table('othertable', meta,
Column('id', Integer, primary_key=True),
Column('myid', Integer, ForeignKey('mytable.myid')),
test_needs_fk=True,
)
meta2 = MetaData()
table_c = table.tometadata(meta2, schema=None)
table2_c = table2.tometadata(meta2, schema=None)
eq_(str(table_c.join(table2_c).onclause), str(table_c.c.myid
== table2_c.c.myid))
eq_(str(table_c.join(table2_c).onclause),
'mytable.myid = othertable.myid')
示例2: test_tometadata_already_there
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import tometadata [as 别名]
def test_tometadata_already_there(self):
meta1 = MetaData()
table1 = Table('mytable', meta1,
Column('myid', Integer, primary_key=True),
)
meta2 = MetaData()
table2 = Table('mytable', meta2,
Column('yourid', Integer, primary_key=True),
)
table_c = table1.tometadata(meta2)
table_d = table2.tometadata(meta2)
# d'oh!
assert table_c is table_d
示例3: test_tometadata_kwargs
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import tometadata [as 别名]
def test_tometadata_kwargs(self):
meta = MetaData()
table = Table('mytable', meta,
Column('myid', Integer, primary_key=True),
mysql_engine='InnoDB',
)
meta2 = MetaData()
table_c = table.tometadata(meta2)
eq_(table.kwargs,table_c.kwargs)
示例4: test_tometadata_indexes
# 需要导入模块: from test.lib.schema import Table [as 别名]
# 或者: from test.lib.schema.Table import tometadata [as 别名]
def test_tometadata_indexes(self):
meta = MetaData()
table = Table('mytable', meta,
Column('id', Integer, primary_key=True),
Column('data1', Integer, index=True),
Column('data2', Integer),
)
Index('multi',table.c.data1,table.c.data2),
meta2 = MetaData()
table_c = table.tometadata(meta2)
def _get_key(i):
return [i.name,i.unique] + \
sorted(i.kwargs.items()) + \
i.columns.keys()
eq_(
sorted([_get_key(i) for i in table.indexes]),
sorted([_get_key(i) for i in table_c.indexes])
)