当前位置: 首页>>代码示例>>Python>>正文


Python UpdateStatement.add_assignment方法代码示例

本文整理汇总了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)
开发者ID:datastax,项目名称:python-driver,代码行数:34,代码来源:test_base_statement.py

示例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'})
开发者ID:Adirio,项目名称:python-driver,代码行数:10,代码来源:test_update_statement.py

示例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))
开发者ID:datastax,项目名称:python-driver,代码行数:11,代码来源:test_update_statement.py

示例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))
开发者ID:Adirio,项目名称:python-driver,代码行数:7,代码来源:test_update_statement.py

示例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'})
开发者ID:Adirio,项目名称:python-driver,代码行数:8,代码来源:test_update_statement.py


注:本文中的cassandra.cqlengine.statements.UpdateStatement.add_assignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。