python - postgres query to extract 1 hour old data using python
问题描述
I am trying to run below code to extract 1 hour old data keeping a check on start_time and end_time. However it is giving error:
Error is: not enough arguments for format string
I cannot understand the error.
curr = datetime.now()
starttime = modules.rounder(curr)
print("Current time rounded off : ", modules.rounder(curr))
cursor.execute("select node_name, node_ip, object_name, start_time, end_time, report_type, rxgemidle, rxploams, rxdroppedtoolong, txploams, fectotal_s, rxpacketsdropped, fec0to1_s, rxallocationsdisabled, rxcrcerrors, rxgem, rxploamserror, fecpost_s, rxgemdropped, rxfeccodewordsuncorrected, txomci, rxbip8bytes, rxploamsdropped, txcpu, rxfragmentserrors, rxploamsnonidle, rxomci, rxfeccodewords, section_interval_valid, fecpre_s, rxbip8errors, rxgemcorrected, rxgemillegal, fec1to0_s, rxkeyerrors, txdroppedtpidmiss, txdroppedillegallength, txgem, fecr_s, rxallocationsvalid, txdroppedvidmiss, rxallocationsinvalid, rxcpu, rxdroppedtooshort, time_interval, data_time from %s where start_time >= %s - interval '1 hour' and end_time <= %s" %data % starttime )
解决方案
推荐阅读
- vba - VBA代码添加一个包含日期的单元格和一个包含数字的单元格,出现不匹配错误
- node.js - Firebase Admin SDK - 使用自定义字段创建用户
- ios - UITableView blurred overlay
- javascript - Node.js 中的计算属性名称 ES5 - 当我动态调用函数时,我的控制台返回 TypeError: Cannot read property of undefined
- python - 从 tfRecords 提取特征时找不到
- android - 包含 ImageView 和 TextView 时,Android 布局不可点击
- aframe - 具有多个对象的 A 帧分数计数器
- python - Django:使用查询参数进行授权
- php - PHP 中的循环耗时,致命错误:超过 120 秒的最大执行时间
- airflow - Airflow DAG 每天运行,不包括周末?