Python: Where it is necessary to complete the transaction?

There is the following code:

for row in arcpy.da.SearchCursor(db_from, fields, where_clause="objectid < 11111"):
 value_from = list(row)
 for rowto in arcpy.da.SearchCursor(db_to, fields, where_clause="uid = '" + str(row[0]) + "'"):
 value_to = list(rowto)
 if(set(value_from) == set(value_to)): # Data is the same
 same +=1
 print "data is old."
 with arcpy.da.UpdateCursor(db_to, fields, where_clause="uid = '" + str(row[0]) + "'") as cursor:
 for x in cursor:
 updated +=1
 print "data update"
 to_cursor.insertRow(value_from) # I think the error is somewhere here
 print "Inserted"

print "Same Data: ", str(same)
print "Updated Data: ", str(updated)

the problem occurs in the following location:

data update
data update
data update
data update
data update
Traceback (most recent call last):
 File "C:\code\Python\work\", line 69, in <module>
 for x in cursor:
Runtime error: workspace already in transaction mode</module>

In what place I need to close tranziciju? As I understand it the problem occurs at the moment when I in DB db_to Deleu at the beginning of the sample, and then try to insert it to do. Right? Update goes fine, but first insert all breaks down.

If I use Isru
July 2nd 19 at 14:13
0 answer

Find more questions by tags Python