当前位置: 首页>>代码示例>>Python>>正文


Python Table.tometadata方法代码示例

本文整理汇总了Python中sqlalchemy.test.schema.Table.tometadata方法的典型用法代码示例。如果您正苦于以下问题:Python Table.tometadata方法的具体用法?Python Table.tometadata怎么用?Python Table.tometadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.test.schema.Table的用法示例。


在下文中一共展示了Table.tometadata方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_tometadata_with_schema

# 需要导入模块: from sqlalchemy.test.schema import Table [as 别名]
# 或者: from sqlalchemy.test.schema.Table import tometadata [as 别名]
    def test_tometadata_with_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="someschema")
        table2_c = table2.tometadata(meta2, schema="someschema")

        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), "someschema.mytable.myid = someschema.othertable.myid")
开发者ID:hughperkins,项目名称:ailadder,代码行数:29,代码来源:test_metadata.py

示例2: test_tometadata_strip_schema

# 需要导入模块: from sqlalchemy.test.schema import Table [as 别名]
# 或者: from sqlalchemy.test.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')
开发者ID:AndryulE,项目名称:kitsune,代码行数:28,代码来源:test_metadata.py

示例3: test_tometadata_already_there

# 需要导入模块: from sqlalchemy.test.schema import Table [as 别名]
# 或者: from sqlalchemy.test.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),
        )

        meta3 = MetaData()

        table_c = table1.tometadata(meta2)
        table_d = table2.tometadata(meta2)

        # d'oh!
        assert table_c is table_d
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:20,代码来源:test_metadata.py

示例4: test_tometadata_kwargs

# 需要导入模块: from sqlalchemy.test.schema import Table [as 别名]
# 或者: from sqlalchemy.test.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)
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:14,代码来源:test_metadata.py

示例5: test_tometadata_indexes

# 需要导入模块: from sqlalchemy.test.schema import Table [as 别名]
# 或者: from sqlalchemy.test.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])
        )
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:24,代码来源:test_metadata.py


注:本文中的sqlalchemy.test.schema.Table.tometadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。