数据库查询不工作

2024-05-16 21:07:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在对数据库执行以下查询:

r.table('skydata').filter(r.row("DeviceID").eq("JBAnFrdlbkcO").and(r.row("TS").ge(0)).and(r.row("TS").le(143556949)) ).orderBy("TS")

当直接在他们网站上的dataexplorer上运行并返回结果时,它工作得非常好。然而,当我在Python程序中进行相同的查询时,却一无所获。我写的问题是:

records = rdb.table('skydata').filter( (rdb.row['DeviceID'] == 'JBAnFrdlbkcO') & (rdb.row['TS'] >= '0') & (rdb.row['TS'] <= '143556949') ).order_by('TS').run(conn)

这里返回的records为空。我认为这两者是等价的。我还尝试直接向服务器发送JS命令:

records = rdb.js("r.table('skydata').filter(r.row('DeviceID').eq(%s).and(r.row('TS').ge(%s)).and(r.row('TS').le(%s)) ).orderBy('TS')" % (deviceid, time_start, time_end) ).run(conn)

但是它说:r is not defined我真的不知道为什么会这样。如果有人能帮忙,我会非常感激的。谢谢。你知道吗


Tags: andrunletablefilterroweqts