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


Python BaseDatabaseCreation.sql_indexes_for_field方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.backends.creation import BaseDatabaseCreation [as 别名]
# 或者: from django.db.backends.creation.BaseDatabaseCreation import sql_indexes_for_field [as 别名]
    def __init__(self):

        try:
            # Add missing index on object_id on AccessControl table
            creation = BaseDatabaseCreation(connection)
            sql = creation.sql_indexes_for_field(
                AccessControl,
                AccessControl._meta.get_field('object_id'),
                no_style(),
            )
            cursor = connection.cursor()
            for s in sql:
                logging.debug("running query %s" % s)
                cursor.execute(s)
                logging.debug("done")
        except:
            logging.exception("error running query")
            #pass

        try:
            # Remove IP based group members
            for group in ExtendedGroup.objects.filter(type=IP_BASED_GROUP):
                logging.debug("deleting users from group %s" % group.id)
                group.user_set.clear()
                logging.debug("done")
        except:
            logging.exception("error deleting users")
            #pass

        # Only need to run once
        raise MiddlewareNotUsed
开发者ID:WMInfoTech,项目名称:rooibos,代码行数:33,代码来源:middleware.py

示例2: __init__

# 需要导入模块: from django.db.backends.creation import BaseDatabaseCreation [as 别名]
# 或者: from django.db.backends.creation.BaseDatabaseCreation import sql_indexes_for_field [as 别名]
    def __init__(self):

        try:
            # Add missing index on object_id on AccessControl table
            creation = BaseDatabaseCreation(connection)
            sql = creation.sql_indexes_for_field(
                AccessControl,
                AccessControl._meta.get_field('object_id'),
                no_style(),
            )
            cursor = connection.cursor()
            for s in sql:
                cursor.execute(s)
        except:
            pass

        try:
            # Remove IP based group members
            for group in ExtendedGroup.objects.filter(type=IP_BASED_GROUP):
                group.user_set.all().delete()
        except:
            pass

        # Only need to run once
        raise MiddlewareNotUsed
开发者ID:hanleybrand,项目名称:mdid_dj16,代码行数:27,代码来源:middleware.py

示例3: __init__

# 需要导入模块: from django.db.backends.creation import BaseDatabaseCreation [as 别名]
# 或者: from django.db.backends.creation.BaseDatabaseCreation import sql_indexes_for_field [as 别名]
    def __init__(self):

        try:
            # Add missing index on object_id on AccessControl table
            creation = BaseDatabaseCreation(connection)
            sql = creation.sql_indexes_for_field(
                AccessControl,
                AccessControl._meta.get_field('object_id'),
                no_style(),
            )
            cursor = connection.cursor()
            for s in sql:
                cursor.execute(s)
        except:
            pass

        # Only need to run once
        raise MiddlewareNotUsed
开发者ID:Blanko2,项目名称:vic-mdid,代码行数:20,代码来源:middleware.py


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