Skip to content Skip to sidebar Skip to footer

Staledataerror: While Updating A Row In A Table With Error : Expected To Update 1 Row(s); 2 Were Matched

I am trying to update a row in a table based on some filters. I could get the row_object and i could update it if the number of rows is one and if more than one it throws StaleData

Solution 1:

I had a similar problem (primarily due to my lack of attention-to-detail). The database table key was different from the key defined in my sql_alchemy models (for that table), which lead sql_alchemy to use a column (the old key) that matched more than one row in the database during the update step of the transaction.

Updating the sql_alchemy model primary key to the actual db primary key fixed the problem.

Post a Comment for "Staledataerror: While Updating A Row In A Table With Error : Expected To Update 1 Row(s); 2 Were Matched"