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


Python exc.UnboundExecutionError方法代码示例

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


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

示例1: do_db_setup

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def do_db_setup():
    """the common routing for setting up the database
    """
    from sqlalchemy.exc import UnboundExecutionError
    from stalker.db.session import DBSession
    try:
        DBSession.connection()
        logger.debug('already connected, not creating any new connections')
    except UnboundExecutionError:
        # DBSession.remove()
        # DBSession.close()
        # no connection do setup
        logger.debug('doing a new connection with NullPool')
        from anima import defaults
        from sqlalchemy.pool import NullPool
        settings = defaults.database_engine_settings
        settings['sqlalchemy.poolclass'] = NullPool
        from stalker import db
        db.setup(settings) 
开发者ID:eoyilmaz,项目名称:anima,代码行数:21,代码来源:__init__.py

示例2: test_create_drop_err_metadata

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def test_create_drop_err_metadata(self):
        metadata = MetaData()
        Table("test_table", metadata, Column("foo", Integer))
        for meth in [metadata.create_all, metadata.drop_all]:
            assert_raises_message(
                exc.UnboundExecutionError,
                "MetaData object is not bound to an Engine or Connection.",
                meth,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:11,代码来源:test_bind.py

示例3: test_create_drop_err_table

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def test_create_drop_err_table(self):
        metadata = MetaData()
        table = Table("test_table", metadata, Column("foo", Integer))

        for meth in [table.create, table.drop]:
            assert_raises_message(
                exc.UnboundExecutionError,
                (
                    "Table object 'test_table' is not bound to an Engine or "
                    "Connection."
                ),
                meth,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:15,代码来源:test_bind.py

示例4: test_clauseelement

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def test_clauseelement(self):
        metadata = MetaData()
        table = Table("test_table", metadata, Column("foo", Integer))
        metadata.create_all(bind=testing.db)
        try:
            for elem in [
                table.select,
                lambda **kwargs: sa.func.current_timestamp(**kwargs).select(),
                # func.current_timestamp().select,
                lambda **kwargs: text("select * from test_table", **kwargs),
            ]:
                for bind in (testing.db, testing.db.connect()):
                    try:
                        e = elem(bind=bind)
                        assert e.bind is bind
                        e.execute().close()
                    finally:
                        if isinstance(bind, engine.Connection):
                            bind.close()

                e = elem()
                assert e.bind is None
                assert_raises(exc.UnboundExecutionError, e.execute)
        finally:
            if isinstance(bind, engine.Connection):
                bind.close()
            metadata.drop_all(bind=testing.db) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:29,代码来源:test_bind.py

示例5: __eq__

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def __eq__(self, other):
        """'Deep, sparse compare.

        Deeply compare two entities, following the non-None attributes of the
        non-persisted object, if possible.

        """
        if other is self:
            return True
        elif not self.__class__ == other.__class__:
            return False

        if id(self) in _recursion_stack:
            return True
        _recursion_stack.add(id(self))

        try:
            # pick the entity that's not SA persisted as the source
            try:
                self_key = sa.orm.attributes.instance_state(self).key
            except sa.orm.exc.NO_STATE:
                self_key = None

            if other is None:
                a = self
                b = other
            elif self_key is not None:
                a = other
                b = self
            else:
                a = self
                b = other

            for attr in list(a.__dict__):
                if attr.startswith('_'):
                    continue
                value = getattr(a, attr)

                try:
                    # handle lazy loader errors
                    battr = getattr(b, attr)
                except (AttributeError, sa_exc.UnboundExecutionError):
                    return False

                if hasattr(value, '__iter__'):
                    if hasattr(value, '__getitem__') and not hasattr(
                            value, 'keys'):
                        if list(value) != list(battr):
                            return False
                    else:
                        if set(value) != set(battr):
                            return False
                else:
                    if value is not None and value != battr:
                        return False
            return True
        finally:
            _recursion_stack.remove(id(self)) 
开发者ID:jpush,项目名称:jbox,代码行数:60,代码来源:entities.py

示例6: __eq__

# 需要导入模块: from sqlalchemy import exc [as 别名]
# 或者: from sqlalchemy.exc import UnboundExecutionError [as 别名]
def __eq__(self, other):
        """'Deep, sparse compare.

        Deeply compare two entities, following the non-None attributes of the
        non-persisted object, if possible.

        """
        if other is self:
            return True
        elif not self.__class__ == other.__class__:
            return False

        if id(self) in _recursion_stack:
            return True
        _recursion_stack.add(id(self))

        try:
            # pick the entity thats not SA persisted as the source
            try:
                self_key = sa.orm.attributes.instance_state(self).key
            except sa.orm.exc.NO_STATE:
                self_key = None

            if other is None:
                a = self
                b = other
            elif self_key is not None:
                a = other
                b = self
            else:
                a = self
                b = other

            for attr in list(a.__dict__):
                if attr.startswith('_'):
                    continue
                value = getattr(a, attr)

                try:
                    # handle lazy loader errors
                    battr = getattr(b, attr)
                except (AttributeError, sa_exc.UnboundExecutionError):
                    return False

                if hasattr(value, '__iter__'):
                    if hasattr(value, '__getitem__') and not hasattr(value, 'keys'):
                        if list(value) != list(battr):
                            return False
                    else:
                        if set(value) != set(battr):
                            return False
                else:
                    if value is not None and value != battr:
                        return False
            return True
        finally:
            _recursion_stack.remove(id(self)) 
开发者ID:binhex,项目名称:moviegrabber,代码行数:59,代码来源:entities.py


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