简体   繁体   English

当我使用时间戳字符串时,cql 查询语句不起作用

[英]cql query statement is not working when i using timestamp string

在此处输入图像描述 在此处输入图像描述

what is the problem in my code?我的代码有什么问题?

It's likely that there are special characters in the variables causing an issue.变量中可能有特殊字符导致问题。 A prepared statement is a good way to insulate against that.准备好的声明是一种避免这种情况的好方法。 So instead of this:所以代替这个:

session.execute("INSERT INTO test_table(id,time) VALUES ({},{});".format(uuid.uuid1(),timestamp))

Try using a prepared statement, like this:尝试使用准备好的语句,如下所示:

strCQL = "INSERT INTO test_table(id,time) VALUES (?,?);"
pStatement = session.prepare(strCQL)
session.execute(pStatement,[uuid.uuid1(),timestamp])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CQL更新查询无法使用Python工作 - CQL update query not working using Python 使用 Python 和 CQL 时如何从 Cassandra 返回时间戳? - How do you return the timestamp from Cassandra when using Python and CQL? pandas 在我使用时间戳列查询时自动转换时间戳列? 如何获得与 postgres 数据库中相同的数据? - pandas automatically converting timestamp columns when i query using timestamp columns? how can i get the same data as it is in the postgres db? 使用pandas时如何将时间戳转换为字符串 - How to convert timestamp to string when using pandas 如何将时间戳(使用 GETDATE())添加到我的插入语句中? - How do I add timestamp (using GETDATE()) to my insert statement? 如何使用Python3在CQL中准备SELECT查询? - How to have a SELECT query prepared in CQL using Python3? 如果使用随机数时语句不起作用 - If statement not working when using random numbers 当语句无法使用 args 时的雪花案例 - Snowflake case when statement not working using args 在 Mac OS 中使用 python 将时间字符串转换为时间戳时不一致 - Inconsistence when converting time string to timestamp using python in Mac OS Python Cassandra cql:插入时间戳和Blob - Python Cassandra cql: INSERT timestamp and blob
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM