當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。