Wednesday, 15 September 2010

how to use begin transaction for multiple queries and different tables (sqlite3, python) -


I am using the following code to insert data into 2 tables:

  1. Variation
  2. # bgn transaction cur.execute ("start") id_var = 0 for prop_redirect ["result"] ["bines"]: Var_res = red ["x"] ["value"]. Partition ('/') [- 1] var_type = "t1" #inert data table VARIATIONS cur.execute ("INSERT INVERATIONS VALUES (ID, NAME, TYPE)", (Str (id_var) + Data entry VAR_ENTITY cur.execute ("VAR_ENTITY INSERT (ID_ENTITY, ID_VAR, LANGUAGE) values ​​(?,?,?)", (Str (IDE), var_res, var_type), strag ID_var = id_var + 1 #

    "Start transaction" and "Commit" (ID_WR) + "_" + str (ID), "N" Allows


    what is cur.execute ("start") and cur.execute ("commit" ) Is the statement correctly placed?

    If the statements are for at the same level , then they are in the right place, but you also have to determine when cur.execute () . < If / Code> calls, then no commitment will be made to do anything other than any code to algorithm_level .

    You should not use cur.execute ("commit") , but conn.commit () hence the driver can see that you What are they doing.

    Start is not really necessary either. If none, then the database will automatically start a transaction for you, then it would be better:

      conn.isolation_level = '...' # is nothing but no code : # For handle transaction management = conn.cursor () for ... Cur.execute (...)  

No comments:

Post a Comment