title: Invalid datetime format in Postgresql query in Python
body: <p>I have a txt file, which contains lines:</p>
  
  <pre><code>Date=28/11/2016
  Time=12:16:06
  </code></pre>
  
  <p>I want to create SQL-query, so I need to format them in true way.</p>
  
  <pre><code>connect = psycopg2.connect(database='eco_db', user='postgres', host='localhost', password='1111', port=5433)
  cursor = connect.cursor()
  
  entry=list()
  for line in infile:
      line = line.strip()
      value = line.split('=', 1)
      entry.append(value[1])
  
  sql_query=str(entry[0] + ' '+entry[1])
  
  
  SQL = '''
  INSERT INTO eco.noise (time) VALUES (%s);
  
  '''
  data = (sql_query)
  cursor.execute(SQL, data)
  
  connect.commit()
  cursor.close()
  connect.close()
  </code></pre>
  
  <p>But the sql_query has a wrong format.
  Mayve I should use datetime package?
  Many thanks.</p>
  
  <p>ERROR:</p>
  
  <pre><code>    cursor.execute(SQL, data)
  psycopg2.DataError: date/time field value out of range: "28/11/2016 12:16:06"
  LINE 2: ...ERT INTO eco.noise (time_noise) VALUES ('28/11/201...
                                                               ^
  HINT:  Perhaps you need a different "datestyle" setting.
  </code></pre>
  
  <p>Solution: use datetime.strptime(YOUR_DATE, '%d/%m/%Y'), where '%d/%m/%Y' - some format.</p>