title: How to make a dynamic SQL query?
body: <p>So I'm inserting some code into my SQL database from an API that
  fetches some data for me. The thing is the amount of "types" and "values" varies
  in the data it gives me, ranging from 7 - 10.</p>
  
  <p>I'm currently formatting a string containing my SQL command. I do this after
  checking the length and then changing the string and format depending on
  the length of "values" (the same as "types"; each "values" has a corresponding type).</p>
  
  <p>I'm kind of a newbie at coding in Python so feel free to toss me some new
  ideas of ways to tackle this problem, thanks and here's my code:</p>
  
  <pre><code>if len(values) == 10:
      cmd = """INSERT INTO children_test_2 ({}, {}, {}, {}, {}, {}, {}, {}, {}) 
      VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {});"""
      cmd = cmd.format(types[0], types[1], types[2], types[3], types[4], types[5], types[6], types[7], types[8],
                       types[9], values[0], values[1], values[2], values[3], values[4], values[5], values[6],
                       values[7], values[8], values[9])
  if len(values) == 9:
      cmd = """INSERT INTO children_test_2 ({}, {}, {}, {}, {}, {}, {}, {}, {}) 
      VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {});"""
      cmd = cmd.format(types[0], types[1], types[2], types[3], types[4], types[5], types[6], types[7], types[8],
                 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8])
  if len(values) == 8:
      cmd = """INSERT INTO children_test_2 ({}, {}, {}, {}, {}, {}, {}, {}) 
      VALUES ({}, {}, {}, {}, {}, {}, {}, {});"""
      cmd = cmd.format(types[0], types[1], types[2], types[3], types[4], types[5], types[6], types[7],
                 values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7])
  if len(values) == 7:
      cmd = """INSERT INTO children_test_2 ({}, {}, {}, {}, {}, {}, {}) 
      VALUES ({}, {}, {}, {}, {}, {}, {});"""
      cmd = cmd.format(types[0], types[1], types[2], types[3], types[4], types[5], types[6],
                 values[0], values[1], values[2], values[3], values[4], values[5], values[6])
  </code></pre>