本文整理汇总了Python中django.db.models.sql.constants.CURSOR属性的典型用法代码示例。如果您正苦于以下问题:Python constants.CURSOR属性的具体用法?Python constants.CURSOR怎么用?Python constants.CURSOR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类django.db.models.sql.constants
的用法示例。
在下文中一共展示了constants.CURSOR属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def update(self, **kwargs):
"""
Update all elements in the current QuerySet, setting all the given
fields to the appropriate values.
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
self._for_write = True
query = self.query.chain(sql.UpdateQuery)
query.add_update_values(kwargs)
# Clear any annotations so that they won't be present in subqueries.
query._annotations = None
with transaction.atomic(using=self.db, savepoint=False):
rows = query.get_compiler(self.db).execute_sql(CURSOR)
self._result_cache = None
return rows
示例2: update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def update(self, **kwargs):
"""
Updates all elements in the current QuerySet, setting all the given
fields to the appropriate values.
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
self._for_write = True
query = self.query.clone(sql.UpdateQuery)
query.add_update_values(kwargs)
# Clear any annotations so that they won't be present in subqueries.
query._annotations = None
with transaction.atomic(using=self.db, savepoint=False):
rows = query.get_compiler(self.db).execute_sql(CURSOR)
self._result_cache = None
return rows
示例3: update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def update(self, **kwargs):
"""
Updates all elements in the current QuerySet, setting all the given
fields to the appropriate values.
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
self._for_write = True
query = self.query.clone(sql.UpdateQuery)
query.add_update_values(kwargs)
with transaction.atomic(using=self.db, savepoint=False):
rows = query.get_compiler(self.db).execute_sql(CURSOR)
self._result_cache = None
return rows
示例4: _update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def _update(self, values):
"""
A version of update that accepts field objects instead of field names.
Used primarily for model saving and not intended for use by general
code (it requires too much poking around at model internals to be
useful at that level).
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
query = self.query.clone(sql.UpdateQuery)
query.add_update_fields(values)
self._result_cache = None
return query.get_compiler(self.db).execute_sql(CURSOR)
示例5: _update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def _update(self, values):
"""
A version of update() that accepts field objects instead of field names.
Used primarily for model saving and not intended for use by general
code (it requires too much poking around at model internals to be
useful at that level).
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
query = self.query.chain(sql.UpdateQuery)
query.add_update_fields(values)
self._result_cache = None
return query.get_compiler(self.db).execute_sql(CURSOR)
示例6: _update
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def _update(self, values):
"""
A version of update() that accepts field objects instead of field names.
Used primarily for model saving and not intended for use by general
code (it requires too much poking around at model internals to be
useful at that level).
"""
assert self.query.can_filter(), \
"Cannot update a query once a slice has been taken."
query = self.query.chain(sql.UpdateQuery)
query.add_update_fields(values)
# Clear any annotations so that they won't be present in subqueries.
query._annotations = None
self._result_cache = None
return query.get_compiler(self.db).execute_sql(CURSOR)
示例7: test_query_encoding
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def test_query_encoding(self):
"""
last_executed_query() returns an Unicode string
"""
data = RawData.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1})
sql, params = data.query.sql_with_params()
cursor = data.query.get_compiler('default').execute_sql(CURSOR)
last_sql = cursor.db.ops.last_executed_query(cursor, sql, params)
self.assertIsInstance(last_sql, six.text_type)
示例8: test_query_encoding
# 需要导入模块: from django.db.models.sql import constants [as 别名]
# 或者: from django.db.models.sql.constants import CURSOR [as 别名]
def test_query_encoding(self):
"""last_executed_query() returns a string."""
data = RawData.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1})
sql, params = data.query.sql_with_params()
cursor = data.query.get_compiler('default').execute_sql(CURSOR)
last_sql = cursor.db.ops.last_executed_query(cursor, sql, params)
self.assertIsInstance(last_sql, str)