title: SQLite get id and insert when using executemany
body: <p>I am optimising my code, and reducing the amount of queries. These used to be in a loop but I am trying to restructure my code to be done like this. How do I get the second query working so that it uses the id entered in the first query from each row. Assume that the datasets are in the right order too. </p>
  
  <pre><code>self.c.executemany("INSERT INTO nodes (node_value, node_group) values (?, (SELECT node_group FROM nodes WHERE node_id = ?)+1)", new_values)
  #my problem is here
  new_id = self.c.lastrowid
  connection_values.append((node_id, new_id))
  #insert entry
  self.c.executemany("INSERT INTO connections (parent, child, strength) VALUES (?,?,1)", connection_values)
  </code></pre>
  
  <p>These queries used to be a for loop but were taking too long so I am trying to avoid using a for loop and doing the query individually. I believe their might be a way with combining it into one query but I am unsure how this would be done. </p>