本文整理汇总了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
示例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
示例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