title: How can in insert tuple data with python in postgres
body: <p>I have the header dict as this</p>
  
  <pre><code>header= {
  'catA' : {
  'name': 'user_name',
  'age':'user_age'
  },
  'catB' : {
  'name': 'person_name',
  'age': 'person_age'
  }
  }
  </code></pre>
  
  <p>The postgres table is flat with all columns from header like this</p>
  
  <p><code>user_name , user_age, person_name, person_age</code></p>
  
  <p>The data which i want to insert looks like this, one row per row in DB</p>
  
  <p>data = <code>[('user_name', 'john'), ('user_age', '23'), ('person_name', 'rupan') . . . ]</code></p>
  
  <p>what is best way to insert</p>
  
  <p>I want something like this</p>
  
  <p><code>query = "INSERT INTO mytable (header.cols) VALUES (data)"</code></p>
  
  <p>Also i want to esacpe the data so that no malacious data goes in database</p>