title: Waiting for a record in Oracle using python and take an action
body: <p>In my first python project, I need to wait for a record to be inserted in an Oracle table. When the record is there, a python function should be called. I'm using cx_oracle.</p>
  
  <p>The way I am doing it now, is to have an infinite loop and in the loop query the table. If the record is there, call the function. After wait for 5 seconds and start again. Something like this:</p>
  
  <pre><code>while 1:
    id = db.cursor.callfunc('FunctionThatReturnsID_OR_0_ifNoRecords', int)
    if id &gt; 0:
      doSomething()
      delete_the_Record(id)
    time.sleep(5)
  </code></pre>
  
  <p>5 seconds is too much time and the system looks slow, but I don't want to overflow the database with queries every second. Is there any other way to wait for a record in python and do some action when the record is inserted?</p>