cassandra - The same query work with cql but not with python driver

五迷三道 提交于 2019-12-11 02:36:25

问题


I have a strange problem here. I have a cassandra table called events_prime and I want to request the DB to get elements from this table with a WHERE clause.

I am using the python cassandra-driver and this is my request:

prep_stment = session.prepare("""
    SELECT * FROM events_prime WHERE "websiteId" = '%s-%s' AND churner=True AND "currentTime" > '%s' AND "currentTime" < '%s' LIMIT 20000;
    """%(platform,client,time_2,time_1))
    print prep_stment
    print "Request DB..."
    frames = []
    for res in session.execute(prep_stment):
        frames.append(pd.DataFrame(res))
    df = pd.concat(frames)
    print df.shape

The output:

Out[1]: Request cassandra...
Out[2]: <PreparedStatement query="
    SELECT * FROM events_prime WHERE "websiteId" = 'sd-8231' AND churner=True AND "currentTime" > '2016-03-08 21:32:14' AND "currentTime" < '2016-03-08 23:32:14' LIMIT 20000;
    ", consistency=Not Set>
Out[3]: Request DB...

Out[4]: (0, 31)

That means that there is no data with the given constraints!

BUT when I run SELECT * FROM events_prime WHERE "websiteId" = 'sd-8231' AND churner=True AND "currentTime" > '2016-03-08 21:32:14' AND "currentTime" < '2016-03-08 23:32:14' LIMIT 20000; (which is the same query in python driver ) directly in cql I get 100 rows?

Any explanation? Thanks in advance

来源:https://stackoverflow.com/questions/35880249/cassandra-the-same-query-work-with-cql-but-not-with-python-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!