title: Getting error while adding data to postgresql table using psycopg2
body: <p>I have a tuple as </p>
  
  <pre><code>final_weather_data = ({'date': '2016-05-11 13:22:58', 
    'place_id': '001D0A00B36E', 'barometer_unit': 'hPa', 
    'weather station name': 'NPCL Hatewa Substation',
    'wind_dir_unit': 'degree', 'temperature': 31.2, 
    'barometer': 1007.9, 'temp_unit': 'C', 'hum_unit': '%', 
    'wind_unit': 'km/h', 'wind_direction': 'NE nbsp 49', 
    'humidity': 60, 'wind_speed': 8.0}) 
  </code></pre>
  
  <p>I am trying to push it into a postgres table by </p>
  
  <pre><code>try:
  
  con = psycopg2.connect("dbname='WeatherForecast' user='postgres' host='localhost' password='postgres'")
  cur = con.cursor()
  cur.mogrify("""INSERT INTO weather_data(temperature,temp_unit,humidity,hum_unit,wind,wind_speed_status,wind_unit,wind_dir,wind_dir_unit,barometer,bar_unit,updated_on,station_id) VALUES (%(temperature)s, %(temp_unit)s, %(humidity)s, %(hum_unit)s, %(wind)s, %(wind_speed_status)s, %(wind_unit)s, %(wind_dir)s, %(wind_dir_unit)s, %(barometer)s, %(bar_unit)s, %(updated_on)s, %(station_id)s);""", final_weather_data)
  ver = cur.fetchone()
  print(ver)
  
  
  except psycopg2.DatabaseError as e:
    print('Error {}'.format(e))
    sys.exit(1)
  
  
  finally:
  
    if con:
      con.close()
  </code></pre>
  
  <p>When i run the above code, it is raising an error "TypeError: tuple indices must be integers, not str".
  Instead , if i try like this
  I am following this <a href="https://wiki.postgresql.org/wiki/Psycopg2_Tutorial" rel="nofollow">https://wiki.postgresql.org/wiki/Psycopg2_Tutorial</a></p>