SQLA itself can only give you "what's changed" in memory. so if you had an X(), and you set X.y to "bar" where it used to be "foo", before a flush you can see that happen with session.dirty and attributes.get_history(x, "y").
I don't entirely understand the actual task here but if it has to do with comparing the contents of one database to another, the general way to do that is to load the objects, populate them with the data from the second database, then use .dirty to see that. Clearly, if you are using that technique, you should do the "compare" job on clean objects, otherwise you can't be sure what changes are from the compare and what changes might have been local. I don't really understand the problem with the "0" and doing it later - if there's some state on the object that determines the "0" and that state is blown away by setting new attributes from the other database, then either don't overwrite those particular attributes or save the important state elsewhere on the object or in a dictionary. On Sep 27, 2011, at 6:56 PM, Brian wrote: > I'm not sure how I could do that because I'd want to set active to 0 only on > the students that are no longer going to school here. > > Maybe merge isn't the right thing to do, or maybe I need to rethink my > algorithm. The bottom line is I need to know what records get added to the > local database table (new users), what ones were active before -- but now I > don't see them in the query (disable users), and what records were changed > (modify/update users). > > What I'm trying right now is to use session.expunge() on each active student, > THEN merge the data from the SIS. That way (I hope) that only records that > changed or added would be "dirty" with an active attribute of 1 and the dirty > objects with an attribute of 0 would need to be removed. > > If anyone has a bright idea I'm all ears. I just don't know SA well enough > to know all the tools available to me for this. > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sqlalchemy/-/Qk7ieEmaC98J. > 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. -- 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.