On Sun, 7 Sep 2008 15:31:56 -0700 (PDT)
sandro dentella <[EMAIL PROTECTED]> wrote:

> 
> Hi,
> 
> I'm trying to flush deletion of single objects w/o triggering a
> complete commit and even after reading the docs several time I think I
> have not got it right. In a little test I manage to do it correctly: I
> delete/ flush single objects and they are DELETEd from the table (at
> least this seems to me...)
> 
> In the  GUI I use as test, thoght objects are flushed but they come
> back unless I issue a session.commit().
> 

Hmm. If by "come back" you mean they show back up in a separate session
and still exist in the database, then it may be that you've forgotten to
commit the transaction at all. If you turn off autocommit, transactions
are never committed except by explicitly calling commit().

If on the other hand you mean that the objects still show up in
collections and so forth while using the same session, you might need to
use session.refresh(obj) or session.expire(obj) to cause any collections
on "obj" to be updated to see the changes. Calling commit() implicitly
expires all loaded objects, while flush() does not.

You can also use session.expunge(obj) or session.expunge_all() to make
the session "forget about" one object or all objects, respectively.

> At that point I realized that I didn't really understand what would be
> the difference between:
> 
>   flush()
>   commit()
> 
> I did understand that commit issues a flush... but then... what is a
> flush w/o a commit?
> 
> I do see that after flushing session.dirty is empty and setting
> bind.echo = True shows:
> 
> DELETE <sqlkit.db.proxy.director_class object at 0x8bb260c>
> 2008-09-08 00:24:16,882 INFO sqlalchemy.engine.base.Engine.0x...e0cc
> DELETE FROM director WHERE director.id = ?
> 2008-09-08 00:24:16,882 INFO sqlalchemy.engine.base.Engine.0x...e0cc
> [19]
> DIRTY IdentitySet([]),
> 
> Nevertheless if I don't issue a session.commit() the objects I deleted
> come back. (Using sqlite for the test. session.autoflush = True,
> autocommit=False )
> 
> Thanks for any explanation
> sandro
> *:-)
>

-Kyle

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to