我正在使用Cassandra Datastax驱动程序执行delete查询,它对数据库没有任何影响。当我通过cqlsh运行完全相同的查询时,它工作得很好。
DEL_QUERY = "DELETE FROM x.user_data WHERE username='{0}' AND usertype = 17;".format(NEW_ID)
logger.debug("Query:\n %r", DEL_QUERY)
cluster = Cluster([CASSANDRA_HOST], port=CASSANDRA_PORT, cql_version=CASSANDRA_CQL_VERSION, auth_provider=CASSANDRA_AUTH_PROVIDER, protocol_version=3)
session = cluster.connect(CASSANDRA_KEYSPACE)
logger.debug("Executing Query:\n" + DEL_QUERY)
if not test_run:
session.execute(DEL_QUERY)
logger.debug("Query Executed.")
cluster.shutdown()以下代码在终端中的结果:
2017-03-27 18:30:10,588 - del - Executing Query:
"DELETE FROM x.user_data WHERE username='9999999999' AND usertype = 17"
2017-03-27 18:30:10,630 - del - Query Executed.我的查询字符串的格式有什么问题吗?
(我现在已经将查询包装在try/except中,并且它不会打印异常消息)
发布于 2017-03-26 17:11:33
看起来你在“格式化”查询时遇到了问题。
https://stackoverflow.com/questions/43008289
复制相似问题