title: Inserting datetime into database using pyscopg2 and PostgreSQL
body: <p>I'm having trouble inserting a datetime stamp into a sql database using the insert statement with pyscopg2.</p>
  
  <p>What the code below does is every time the button is pushed, it should insert a row into the database containing the buildingID(which is just text) and the date and time when the button was pressed.</p>
  
  <p>I just can't figure out how to insert the current date and time.</p>
  
  <pre><code># Inserts data into local database
  def insertLocalDB():
      # Open a cursor to perform database operations
      cur = conn.cursor()
      cur.execute("INSERT INTO test_table (buildingID,datetime) VALUES(%s,%s)",
      ("01", datetime))  #HAS TO BE CURRENT DATE AND TIME
      # Make the changes to the database persistant
      conn.commit()
      # Close communication with the database
      cur.close()
  </code></pre>