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


Python base.BaseDatabaseWrapper方法代码示例

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


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

示例1: test_instance

# 需要导入模块: from django.db.backends.base import base [as 别名]
# 或者: from django.db.backends.base.base import BaseDatabaseWrapper [as 别名]
def test_instance():
    settings_dict = {
    }

    driver = base.DatabaseWrapper(settings_dict)
    assert isinstance(driver, BaseDatabaseWrapper) 
开发者ID:pablotcarreira,项目名称:django-arangodb,代码行数:8,代码来源:test_arangodb_driver.py

示例2: assertConnectionsEnabled

# 需要导入模块: from django.db.backends.base import base [as 别名]
# 或者: from django.db.backends.base.base import BaseDatabaseWrapper [as 别名]
def assertConnectionsEnabled(self):
        for alias in connections:
            self.assertThat(
                connections[alias], IsInstance(BaseDatabaseWrapper)
            ) 
开发者ID:maas,项目名称:maas,代码行数:7,代码来源:test_orm.py

示例3: monkeypatch_django

# 需要导入模块: from django.db.backends.base import base [as 别名]
# 或者: from django.db.backends.base.base import BaseDatabaseWrapper [as 别名]
def monkeypatch_django() -> None:
    def ensure_connection_with_retries(self: django_db_base.BaseDatabaseWrapper) -> None:
        if self.connection is not None and hasattr(self.connection, 'closed') and self.connection.closed:
            _log.debug("failed connection detected")
            self.connection = None

        if self.connection is None and not hasattr(self, '_in_connecting'):
            with self.wrap_database_errors:
                try:
                    self._in_connecting = True
                    self.connect()
                except Exception as e:
                    if isinstance(e, _operror_types):
                        if hasattr(self, "_connection_retries") and self._connection_retries >= 1:
                            _log.error("Reconnecting to the database didn't help %s", str(e))
                            del self._in_connecting
                            post_reconnect.send(self.__class__, dbwrapper=self)
                            raise
                        else:
                            _log.info("Database connection failed. Refreshing...")
                            # mark the retry
                            self._connection_retries = 1
                            # ensure that we retry the connection. Sometimes .closed isn't set correctly.
                            self.connection = None
                            del self._in_connecting

                            # give libraries like 12factor-vault the chance to update the credentials
                            pre_reconnect.send(self.__class__, dbwrapper=self)
                            self.ensure_connection()
                            post_reconnect.send(self.__class__, dbwrapper=self)
                    else:
                        _log.debug("Database connection failed, but not due to a known error for dbconn_retry %s",
                                   str(e))
                        del self._in_connecting
                        raise
                else:
                    # connection successful, reset the flag
                    self._connection_retries = 0
                    del self._in_connecting

    _log.debug("django_dbconn_retry: monkeypatching BaseDatabaseWrapper")
    django_db_base.BaseDatabaseWrapper.ensure_connection = ensure_connection_with_retries 
开发者ID:jdelic,项目名称:django-dbconn-retry,代码行数:44,代码来源:__init__.py


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