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."
else:
 with arcpy.da.UpdateCursor(db_to, fields, where_clause="uid = '" + str(row[0]) + "'") as cursor:
 for x in cursor:
cursor.updateRow(value_from)
 updated +=1
 print "data update"
else:
 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
Inserted
Traceback (most recent call last):
 File "C:\code\Python\work\dbsync.py", 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