title: how to use begin transaction for multiple queries and different tables (sqlite3, python)
body: <p>I am using the following code in order to insert data in 2 tables:</p>
  
  <ol>
  <li>Variations</li>
  <li>Var_entity</li>
  </ol>
  
  <hr>
  
  <pre><code>    #begin transaction
      cur.execute("begin")
      id_var = 0
      for red in prop_redirect["results"]["bindings"]:
          var_res = red["x"]["value"].split('/')[-1]
          var_type = "t1"
          #insert data in table VARIATIONS
          cur.execute("INSERT INTO VARIATIONS (ID, NAME, TYPE) VALUES (?, ?, ?)", (str(id_var) + "_" + str(ID), var_res, var_type))
          #insert data in table VAR_ENTITY
          cur.execute("INSERT INTO VAR_ENTITY(ID_ENTITY, ID_VAR, LANGUAGE) VALUES(?, ?, ?)", (str(ID), str(id_var) + "_" + str(ID), "en" ) )
          id_var = id_var + 1 
      #commit after for loop
      cur.execute("commit")
  </code></pre>
  
  <hr>
  
  <p>From what I understood, using "begin transaction" and "commit" allows a faster access to the database <a href="https://stackoverflow.com/questions/18219779/bulk-insert-huge-data-into-sqlite-using-python">Bulk insert huge data into SQLite using Python</a></p>
  
  <hr>
  
  <p>Are the <code>cur.execute("begin")</code> and <code>cur.execute("commit")</code> statements placed correctly? </p>
  
  <hr>
  
  <p>Previous questions that I found on stackoverflow:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2887878/importing-a-csv-file-into-a-sqlite3-database-table-using-python/2888042#2888042">Importing a CSV file into a sqlite3 database table using Python</a></li>
  <li><a href="https://stackoverflow.com/questions/7238836/how-to-prepogate-transaction-for-multiple-request">how to prepogate transaction for multiple request</a></li>
  </ul>