如何从数据库收集一天的记录?

发布于 2025-01-16 12:15:54 字数 435 浏览 2 评论 0原文

我正在尝试收集一日记录表格数据库。以下是我的查询,它给出的错误为 psycopg2.errors.InvalidTextRepresentation:整数输入语法无效:

代码:

`start_epoctime = time.mktime(start.timetuple()) + start.microsecond * 1e-6

end_epoctime = time.mktime(end.timetuple()) + end。微秒 * 1e-6

start_epoctime = int(start_epoctime - 19800) end_epoctime = int(end_epoctime - 19800) PostgreSQL: 选择 station_number,ccu_time,其中 ccu_time 在 start_epoctime 和 end_epoctime 之间`

Im trying to collect a one day record form db. The below is my query it giving error as
psycopg2.errors.InvalidTextRepresentation: invalid input syntax for integer:

Code:

`start_epoctime = time.mktime(start.timetuple()) + start.microsecond * 1e-6

end_epoctime = time.mktime(end.timetuple()) + end.microsecond * 1e-6

start_epoctime = int(start_epoctime - 19800)
end_epoctime = int(end_epoctime - 19800)
postgresql :
SELECT station_number,ccu_time,where ccu_time between start_epoctime and end_epoctime`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静谧 2025-01-23 12:15:54

ccu_time 是时间戳还是unix时间?
尝试使用以下内容:

SELECT station_number,ccu_time,where ccu_time between '20220301 00:00:00.000' and '20220331 23:59:59.999';

如果 ccu_time 是 unix 时间:

SELECT station_number,ccu_time,where ccu_time > extract(epoch from '20220301 00:00:00.000') and ccu_time < extract(epoch from '20220331 23:59:59.999');

ccu_time is timestamp or unix time?
Try with something like:

SELECT station_number,ccu_time,where ccu_time between '20220301 00:00:00.000' and '20220331 23:59:59.999';

if ccu_time is unix time:

SELECT station_number,ccu_time,where ccu_time > extract(epoch from '20220301 00:00:00.000') and ccu_time < extract(epoch from '20220331 23:59:59.999');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文