无法使用 Python cassandra-driver 查询特定 UUID

Cannot query for particular UUID with Python cassandra-driver

我正在尝试使用 Python 包 cassandra-driver 从我的 cassandra 数据库中提取特定值。我对数据结构没有影响。

我的Python脚本

from cassandra.cluster import Cluster
cluster =Cluster()
session =cluster.connect('thingsboard')
rows =session.execute("SELECT * FROM ts_kv_latest_cf")
for id_row in rows:
    print (id_row)

给出以下输出:

Row(entity_type='DEVICE', entity_id=UUID('5ee30bf0-2e8b-11e8-a810-c3c1a78797ed'), key='count-cola', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521808687455)
Row(entity_type='DEVICE', entity_id=UUID('5ee30bf0-2e8b-11e8-a810-c3c1a78797ed'), key='count-fanta', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521808687455)
Row(entity_type='DEVICE', entity_id=UUID('5ee30bf0-2e8b-11e8-a810-c3c1a78797ed'), key='count-sprite', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521808687455)
Row(entity_type='DEVICE', entity_id=UUID('477b5630-2e8a-11e8-a810-c3c1a78797ed'), key='count-cola', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521803445966)
Row(entity_type='DEVICE', entity_id=UUID('477b5630-2e8a-11e8-a810-c3c1a78797ed'), key='count-fanta', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521803445966)
Row(entity_type='DEVICE', entity_id=UUID('477b5630-2e8a-11e8-a810-c3c1a78797ed'), key='count-sprite', bool_v=None, dbl_v=None, long_v=0, str_v=None, ts=1521803445966)

我现在要做的是这样的查询:

rows =session.execute("SELECT * FROM ts_kv_latest_cf WHERE entity_id=UUID('5ee30bf0-2e8b-11e8-a810-c3c1a78797ed')")

这给了我以下错误:

cassandra.InvalidRequest: Error from server: code=2200 [Invalid query] message="Invalid number of arguments in call to function system.uuid: 0 required but 1 provided"

查询好像调用了系统函数uuid。我知道 entity_iduuid 的类型,但我不知道如何使用 session.execute.

在我的查询中包含它

我用过:

非常感谢任何想法!谢谢。

刚才我遇到了类似的问题。您必须将查询更改为如下内容:

rows =session.execute("SELECT * FROM ts_kv_latest_cf WHERE entity_id=5ee30bf0-2e8b-11e8-a810-c3c1a78797ed")

uuid 必须在前面没有 UUID 的情况下给出。