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


Python Table.drop方法代码示例

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


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

示例1: test_create_drop_bound

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [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()
开发者ID:23andMe,项目名称:sqlalchemy,代码行数:36,代码来源:test_bind.py

示例2: test_fixed_char

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [as 别名]
    def test_fixed_char(self):
        m = MetaData(testing.db)
        t = Table('t1', m,
                  Column('id', Integer, primary_key=True),
                  Column('data', CHAR(30), nullable=False))

        t.create()
        try:
            t.insert().execute(
                dict(id=1, data="value 1"),
                dict(id=2, data="value 2"),
                dict(id=3, data="value 3")
            )

            eq_(
                t.select().where(t.c.data == 'value 2').execute().fetchall(),
                [(2, 'value 2                       ')]
            )

            m2 = MetaData(testing.db)
            t2 = Table('t1', m2, autoload=True)
            assert type(t2.c.data.type) is CHAR
            eq_(
                t2.select().where(t2.c.data == 'value 2').execute().fetchall(),
                [(2, 'value 2                       ')]
            )

        finally:
            t.drop()
开发者ID:eoghanmurray,项目名称:sqlalchemy,代码行数:31,代码来源:test_types.py

示例3: test_checkfirst_table

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [as 别名]
 def test_checkfirst_table(self):
     m = MetaData()
     s = Sequence("my_sequence")
     t = Table('t', m, Column('c', Integer, s, primary_key=True))
     t.create(testing.db, checkfirst=False)
     assert self._has_sequence('my_sequence')
     t.create(testing.db, checkfirst=True)
     t.drop(testing.db, checkfirst=False)
     assert not self._has_sequence('my_sequence')
     t.drop(testing.db, checkfirst=True)
开发者ID:Affirm,项目名称:sqlalchemy,代码行数:12,代码来源:test_defaults.py

示例4: test_create_drop_explicit

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [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])
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:13,代码来源:test_bind.py

示例5: test_create_drop_constructor_bound

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [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()
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:20,代码来源:test_bind.py

示例6: test_rollback_deadlock

# 需要导入模块: from sqlalchemy.testing.schema import Table [as 别名]
# 或者: from sqlalchemy.testing.schema.Table import drop [as 别名]
    def test_rollback_deadlock(self):
        """test that returning connections to the pool clears any object
        locks."""

        conn1 = testing.db.connect()
        conn2 = testing.db.connect()
        users = Table('deadlock_users', metadata, Column('user_id',
                      INT, primary_key=True), Column('user_name',
                      VARCHAR(20)), test_needs_acid=True)
        users.create(conn1)
        conn1.execute('select * from deadlock_users')
        conn1.close()

        # without auto-rollback in the connection pool's return() logic,
        # this deadlocks in PostgreSQL, because conn1 is returned to the
        # pool but still has a lock on "deadlock_users". comment out the
        # rollback in pool/ConnectionFairy._close() to see !

        users.drop(conn2)
        conn2.close()
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:22,代码来源:test_transaction.py


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