本文整理匯總了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