title: postgres query to extract 1 hour old data using python
body: <p>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:</p>
  <blockquote>
  <p>Error is: not enough arguments for format string</p>
  </blockquote>
  <p>I cannot understand the error.</p>
  <pre><code>
  curr = datetime.now()
  starttime = modules.rounder(curr)
  print(&quot;Current time rounded off : &quot;, modules.rounder(curr))
  cursor.execute(&quot;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 &gt;= %s - interval '1 hour' and end_time &lt;= %s&quot; %data % starttime )
  
  </code></pre>