Gloria W wrote:
>
> D'OH! (slaps head)
> Thanks for pointing this out, it makes perfect sense.
> I got it working by getting it from the DB, and merging it into the
> current session, then deleting:
>
>   def DELETE(self,dmemberid):
>     x = MemberInfo()
>     memberProfile = x.GET(memberid=dmemberid,raw=True)
>     merged_obj = self.session.merge(memberProfile[0])
>     self.session.delete(merged_obj)
>     self.session.commit()
>
> Without merging into the same session, I got this error:
>
> sqlalchemy.exc.InvalidRequestError: Object '<MemberProfile at
> 0x-48935294>' is already attached to session '-1217720980' (this is
> '-1217780404')
>
> I'm not sure why a merge into the current session was necessary, since
> I did the get() in the same session. Does each query flush the
> session, and create a new session key behind the scenes?

its definitely not the same session. otherwise "memberProfile[0] is
merged_obj" would return True.


>
> So happy this is working, thank you!
> Gloria
> >
>


--~--~---------~--~----~------------~-------~--~----~
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