BAE
BAE

Reputation: 8956

cassandra: compare timestamp in python

I am using Cassandra Python Driver, a little confused.

res = dbconnection.execute("""select sum(count) from A = a and day >= %s;""", (myday, ));

Cluster key day is timestamp in Cassandra. what myday should be? epoch in milliseconds, OR epoch in seconds, OR string like 2016-10-26 00:00:00? Any performance difference?

Any comments welcomed. Thanks.

Upvotes: 0

Views: 519

Answers (2)

Adam Holmberg
Adam Holmberg

Reputation: 7365

There is a doc page that discusses the details of working with time with the Python driver.

You are correct that it can be either a datetime, or integer milliseconds from epoch.

Integer input would be marginally more efficient, but you will probably not observe any performance difference, since [query time] >> [parameter encoding].

Upvotes: 1

Patrick Haugh
Patrick Haugh

Reputation: 61063

From the link you provided, the python datetime is cast to the CQL timestamp. Read more about datetime here.

Upvotes: 0

Related Questions