本文整理汇总了Python中cassandra.cqlengine.statements.UpdateStatement.add_assignment方法的典型用法代码示例。如果您正苦于以下问题:Python UpdateStatement.add_assignment方法的具体用法?Python UpdateStatement.add_assignment怎么用?Python UpdateStatement.add_assignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cassandra.cqlengine.statements.UpdateStatement
的用法示例。
在下文中一共展示了UpdateStatement.add_assignment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_insert_statement_execute
# 需要导入模块: from cassandra.cqlengine.statements import UpdateStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.UpdateStatement import add_assignment [as 别名]
def test_insert_statement_execute(self):
"""
Test to verify the execution of BaseCQLStatements using connection.execute
@since 3.10
@jira_ticket PYTHON-505
@expected_result inserts a row in C*, updates the rows and then deletes
all the rows using BaseCQLStatements
@test_category data_types:object_mapper
"""
partition = uuid4()
cluster = 1
self._insert_statement(partition, cluster)
# Verifying update statement
where = [WhereClause('partition', EqualsOperator(), partition),
WhereClause('cluster', EqualsOperator(), cluster)]
st = UpdateStatement(self.table_name, where=where)
st.add_assignment(Column(db_field='count'), 2)
st.add_assignment(Column(db_field='text'), "text_for_db_update")
st.add_assignment(Column(db_field='text_set'), set(("foo_update", "bar_update")))
st.add_assignment(Column(db_field='text_list'), ["foo_update", "bar_update"])
st.add_assignment(Column(db_field='text_map'), {"foo": '3', "bar": '4'})
execute(st)
self._verify_statement(st)
# Verifying delete statement
execute(DeleteStatement(self.table_name, where=where))
self.assertEqual(TestQueryUpdateModel.objects.count(), 0)
示例2: test_context_update
# 需要导入模块: from cassandra.cqlengine.statements import UpdateStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.UpdateStatement import add_assignment [as 别名]
def test_context_update(self):
us = UpdateStatement('table')
us.add_assignment(Column(db_field='a'), 'b')
us.add_assignment(Column(db_field='c'), 'd')
us.add_where(Column(db_field='a'), EqualsOperator(), 'x')
us.update_context_id(3)
self.assertEqual(six.text_type(us), 'UPDATE table SET "a" = %(4)s, "c" = %(5)s WHERE "a" = %(3)s')
self.assertEqual(us.get_context(), {'4': 'b', '5': 'd', '3': 'x'})
示例3: test_rendering
# 需要导入模块: from cassandra.cqlengine.statements import UpdateStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.UpdateStatement import add_assignment [as 别名]
def test_rendering(self):
us = UpdateStatement('table')
us.add_assignment(Column(db_field='a'), 'b')
us.add_assignment(Column(db_field='c'), 'd')
us.add_where(Column(db_field='a'), EqualsOperator(), 'x')
self.assertEqual(six.text_type(us), 'UPDATE table SET "a" = %(0)s, "c" = %(1)s WHERE "a" = %(2)s', six.text_type(us))
us.add_where(Column(db_field='a'), NotEqualsOperator(), 'y')
self.assertEqual(six.text_type(us), 'UPDATE table SET "a" = %(0)s, "c" = %(1)s WHERE "a" = %(2)s AND "a" != %(3)s', six.text_type(us))
示例4: test_additional_rendering
# 需要导入模块: from cassandra.cqlengine.statements import UpdateStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.UpdateStatement import add_assignment [as 别名]
def test_additional_rendering(self):
us = UpdateStatement('table', ttl=60)
us.add_assignment(Column(db_field='a'), 'b')
us.add_where(Column(db_field='a'), EqualsOperator(), 'x')
self.assertIn('USING TTL 60', six.text_type(us))
示例5: test_context
# 需要导入模块: from cassandra.cqlengine.statements import UpdateStatement [as 别名]
# 或者: from cassandra.cqlengine.statements.UpdateStatement import add_assignment [as 别名]
def test_context(self):
us = UpdateStatement('table')
us.add_assignment(Column(db_field='a'), 'b')
us.add_assignment(Column(db_field='c'), 'd')
us.add_where(Column(db_field='a'), EqualsOperator(), 'x')
self.assertEqual(us.get_context(), {'0': 'b', '1': 'd', '2': 'x'})