运行查询时。
"select * from temperature_by_day"
Cassandra 返回时间戳字符串“\x00\x00\x017\xa7\xea\x9e\x00”。
如果我从服务器上的 cqlsh 查询,它会返回我设置的日期。
我读过这篇文章:How to retrieve the timestamp from cassandra?
它指出“不建议在客户端代码中直接使用列 Cassandra 时间戳;”。
为什么?这里的教程指出直接查询时间戳。
http://planetcassandra.org/blog/post/getting-started-with-time-series-data-modeling/
那么添加不属于主键的附加时间戳并根据该时间戳进行查询是否正确?
提前致谢。
最佳答案
Datastax Python driver支持时间戳类型。如果您想了解如何反序列化它,请查看 DataType.deserialize方法:
return datetime.utcfromtimestamp(int64_unpack(byts) / 1000.0)
关于python - 使用 Python 和 CQL 时如何从 Cassandra 返回时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22843478/