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


Python connection.features方法代码示例

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


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

示例1: _reset_sequences

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _reset_sequences(self, db_name):
        conn = connections[db_name]
        if conn.features.supports_sequence_reset:
            sql_list = conn.ops.sequence_reset_by_name_sql(
                no_style(), conn.introspection.sequence_list())
            if sql_list:
                with transaction.atomic(using=db_name):
                    cursor = conn.cursor()
                    for sql in sql_list:
                        cursor.execute(sql) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:12,代码来源:testcases.py

示例2: connections_support_transactions

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def connections_support_transactions():
    """
    Returns True if all connections support transactions.
    """
    return all(conn.features.supports_transactions
               for conn in connections.all()) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:testcases.py

示例3: skipIfDBFeature

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipIfDBFeature(*features):
    """
    Skip a test if a database has at least one of the named features.
    """
    return _deferredSkip(
        lambda: any(getattr(connection.features, feature, False) for feature in features),
        "Database has feature(s) %s" % ", ".join(features)
    ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:testcases.py

示例4: skipUnlessDBFeature

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessDBFeature(*features):
    """
    Skip a test unless a database has all the named features.
    """
    return _deferredSkip(
        lambda: not all(getattr(connection.features, feature, False) for feature in features),
        "Database doesn't support feature(s): %s" % ", ".join(features)
    ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:testcases.py

示例5: can_migrate

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def can_migrate(self, connection):
        """
        Return True if the model can/should be migrated on the `connection`.
        `connection` can be either a real connection or a connection alias.
        """
        if self.proxy or self.swapped or not self.managed:
            return False
        if isinstance(connection, str):
            connection = connections[connection]
        if self.required_db_vendor:
            return self.required_db_vendor == connection.vendor
        if self.required_db_features:
            return all(getattr(connection.features, feat, False)
                       for feat in self.required_db_features)
        return True 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:options.py

示例6: connections_support_transactions

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def connections_support_transactions():
    """Return True if all connections support transactions."""
    return all(conn.features.supports_transactions for conn in connections.all()) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:5,代码来源:testcases.py

示例7: _should_check_constraints

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _should_check_constraints(self, connection):
        return (
            connection.features.can_defer_constraint_checks and
            not connection.needs_rollback and connection.is_usable()
        ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:testcases.py

示例8: skipIfDBFeature

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipIfDBFeature(*features):
    """Skip a test if a database has at least one of the named features."""
    return _deferredSkip(
        lambda: any(getattr(connection.features, feature, False) for feature in features),
        "Database has feature(s) %s" % ", ".join(features)
    ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:8,代码来源:testcases.py

示例9: skipUnlessAnyDBFeature

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessAnyDBFeature(*features):
    """Skip a test unless a database has any of the named features."""
    return _deferredSkip(
        lambda: not any(getattr(connection.features, feature, False) for feature in features),
        "Database doesn't support any of the feature(s): %s" % ", ".join(features)
    ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:8,代码来源:testcases.py

示例10: test_mock_django_connection

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def test_mock_django_connection(self, mock_handler):
        is_foo_before = bool(getattr(connection.features, 'is_foo', False))

        mock_django_connection(disabled_features=['is_foo'])

        is_foo_after = bool(getattr(connection.features, 'is_foo', False))

        self.assertTrue(is_foo_before)
        self.assertFalse(is_foo_after)


# noinspection PyUnresolvedReferences,PyStatementEffect 
开发者ID:stphivos,项目名称:django-mock-queries,代码行数:14,代码来源:test_mocks.py

示例11: _reset_sequences

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def _reset_sequences(self, db_name):
        conn = connections[db_name]
        if conn.features.supports_sequence_reset:
            sql_list = conn.ops.sequence_reset_by_name_sql(
                no_style(), conn.introspection.sequence_list())
            if sql_list:
                with transaction.atomic(using=db_name):
                    with conn.cursor() as cursor:
                        for sql in sql_list:
                            cursor.execute(sql) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:12,代码来源:testcases.py

示例12: can_migrate

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def can_migrate(self, connection):
        """
        Return True if the model can/should be migrated on the `connection`.
        `connection` can be either a real connection or a connection alias.
        """
        if self.proxy or self.swapped or not self.managed:
            return False
        if isinstance(connection, six.string_types):
            connection = connections[connection]
        if self.required_db_vendor:
            return self.required_db_vendor == connection.vendor
        if self.required_db_features:
            return all(getattr(connection.features, feat, False)
                       for feat in self.required_db_features)
        return True 
开发者ID:Yeah-Kun,项目名称:python,代码行数:17,代码来源:options.py

示例13: skipUnlessAnyDBFeature

# 需要导入模块: from django.db import connection [as 别名]
# 或者: from django.db.connection import features [as 别名]
def skipUnlessAnyDBFeature(*features):
    """
    Skip a test unless a database has any of the named features.
    """
    return _deferredSkip(
        lambda: not any(getattr(connection.features, feature, False) for feature in features),
        "Database doesn't support any of the feature(s): %s" % ", ".join(features)
    ) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:10,代码来源:testcases.py


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