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


Python utils.CursorWrapper方法代码示例

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


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

示例1: _reconfigureLogging

# 需要导入模块: from django.db.backends import utils [as 别名]
# 或者: from django.db.backends.utils import CursorWrapper [as 别名]
def _reconfigureLogging(self):
        # Reconfigure the logging based on the debug mode of Django.
        from django.conf import settings

        if settings.DEBUG:
            # In debug mode, force logging to debug mode.
            logger.set_verbosity(3)

            # When not in the developer environment, patch Django to not
            # use the debug cursor. This is needed or Django will store in
            # memory every SQL query made.
            from provisioningserver.config import is_dev_environment

            if not is_dev_environment():
                from django.db.backends.base import base
                from django.db.backends.utils import CursorWrapper

                base.BaseDatabaseWrapper.make_debug_cursor = lambda self, cursor: CursorWrapper(
                    cursor, self
                ) 
开发者ID:maas,项目名称:maas,代码行数:22,代码来源:plugin.py

示例2: make_cursor

# 需要导入模块: from django.db.backends import utils [as 别名]
# 或者: from django.db.backends.utils import CursorWrapper [as 别名]
def make_cursor(self, cursor):
        """
        Creates a cursor without debug logging.
        """
        return utils.CursorWrapper(cursor, self) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:base.py

示例3: make_cursor

# 需要导入模块: from django.db.backends import utils [as 别名]
# 或者: from django.db.backends.utils import CursorWrapper [as 别名]
def make_cursor(self, cursor):
        """Create a cursor without debug logging."""
        return utils.CursorWrapper(cursor, self) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:5,代码来源:base.py

示例4: test_cursor_contextmanager

# 需要导入模块: from django.db.backends import utils [as 别名]
# 或者: from django.db.backends.utils import CursorWrapper [as 别名]
def test_cursor_contextmanager(self):
        """
        Cursors can be used as a context manager
        """
        with connection.cursor() as cursor:
            self.assertIsInstance(cursor, CursorWrapper)
        # Both InterfaceError and ProgrammingError seem to be used when
        # accessing closed cursor (psycopg2 has InterfaceError, rest seem
        # to use ProgrammingError).
        with self.assertRaises(connection.features.closed_cursor_error_class):
            # cursor should be closed, so no queries should be possible.
            cursor.execute("SELECT 1" + connection.features.bare_select_suffix) 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:14,代码来源:tests.py

示例5: test_cursor_contextmanager_closing

# 需要导入模块: from django.db.backends import utils [as 别名]
# 或者: from django.db.backends.utils import CursorWrapper [as 别名]
def test_cursor_contextmanager_closing(self):
        # There isn't a generic way to test that cursors are closed, but
        # psycopg2 offers us a way to check that by closed attribute.
        # So, run only on psycopg2 for that reason.
        with connection.cursor() as cursor:
            self.assertIsInstance(cursor, CursorWrapper)
        self.assertTrue(cursor.closed)

    # Unfortunately with sqlite3 the in-memory test database cannot be closed. 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:11,代码来源:tests.py


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