Mike Conley wrote:
> I am getting this error on a session.flush().
>
>     sqlalchemy.orm.exc.ConcurrentModificationError: Updated rowcount 0
> does
> not match number of objects updated 1
>
> and can't figure out where to start looking.

it means an UPDATE was issued towards updating the values of a particular
persistent mapped instance, and that the primary key represented by this
instance did not exist in the database at the time the UPDATE was issued,
so no rows matched the WHERE clause.

Since your operation is a "copy", in theory there should only be INSERTs
and not UPDATEs.   So at the point of your flush(), session.dirty should
be empty, everything pending would be in session.new.   So that's one
place to look.  The other is in SQL logging, you'd see an UPDATE statement
immediately before the exception throw which should indicate exactly what
type of object is targeted as well as what the expected primary key value
of that object is.


>
> The database is sqlite, there are no other users connected to the
> database,
> and only one process running at the time.
>
> This is happening in the middle of a fairly large routine that is copying
> a
> data structure within my database. The routine starts at a high level
> parent
> object and copies the parent and many related children through several
> intertwined relationships resulting in a copy of the parent and all
> related
> rows in the database. Think of it as copying object "X" and everything
> about
> "X" to a new object "Y" that will have a copy of all "X" ' s information.
> There are about 20 tables involved in the process. Periodically in the
> process I need to do a flush() to get the id's of some new objects and it
> is
> in one of  these flush() operations that I get this error.
>
> I'm looking for any help I can get about what could cause the error or
> what
> I should look at to debug it and track down the cause. I am pretty sure it
> will be in my code someplace because this is all new code and I am just in
> the unit testing stage.
>
>
> --
> Mike Conley
>
> >
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to