About the Session.merge(), the documentation gives several examples of use cases, I think there might be a slight ambiguity in this one:
An application which reads an object structure from a file and wishes to > save it to the database might parse the file, build up the structure, and > then use merge() to save it to the database, ensuring that the data within > the file is used to formulate the primary key of each element of the > structure. Later, when the file has changed, the same process can be > re-run, producing a slightly different object structure, which can then be > merged in again, and the Session will automatically update the database to > reflect those changes, loading each object from the database by primary key > and then updating its state with the new state given. In this case when "the same process re-run, producing a slightly different object structure," does this newer object carry a primary key? If it's just been produced by parsing from the file, then I think probably it doesn't have a primary key. If it doesn't have a primary key, then merge() will create an entirely new entry in database for it instead of updating the older one, right? And this would defeat the updating intention, right? I think I probably missed some point here. Could someone elaborate it a little bit? Thanks. p.s. Please bear with me with so many entry-level questions. I've been studying thoroughly the documentation these days and trying to learn the ropes. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.