我正在使用datastax 从表中检索时间戳。我要做的是将先前检索的时间戳存储在var中,并在下一个查询中使用它来检索大于前一个查询的时间戳。查询基本上如下所示:
cqlsh> SELECT insert_time, message FROM cf WHERE message_key='q1' AND insert_time>'2013-10-30 10:32:44+0530' ORDER BY insert_time ASC LIMIT 1;
insert_time | message
---------------
下面的测试总是失败(这是在linux系统上运行的,问题不是关于其他OSes的):
from time import time
from decimal import Decimal
from pathlib import Path
def test_timing():
start = Decimal(time())
p = Path(__file__).parent / 'testfile.txt' # does not yet exist
p.touch()
mt = p.st
通过使用PostgreSQL Python模块psycopg2,我希望找到结束时间在某个时间戳之前的行。我试图在带有cursor.execute(…)的SQL查询上使用… where end_time < %s来实现这一点,其中%s被带有时区的datetime.datetime对象替换。psycopg2生成的SQL是:
select * from my_table where end_time < '2014-05-01T13:00:00+00:00'::timestamptz;
返回如下所示的一行:
id | start_time |