首页 > 解决方案 > 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 )

标签: pythonpsycopg2

解决方案


推荐阅读