you can make a new Session() with expire_on_commit=False, that can be
from your sessionmaker.  the settings you apply there override whats in
the original factory.

Though for status logging I tend to just use a separate
Session/transaction for that, that way the main transaction can maintain
atomicity while the "status" value is visible from the outside.


On 7/8/14, 2:04 PM, Jonathan Vanasco wrote:
> I have a situation where I need to issue a `commit()` without expiring
> the object/attributes from the session.   I'm in a `Celery` task, and
> need to log progress at certain points into a "status" column.  the
> status points will be used to troubleshoot and "fix" jobs that didn't
> correctly complete.
>
> `commit()` doesn't accept an `expire_on_commit` argument -- which
> would suit my needs perfectly -- only the sessionmaker does.
>
> it looks like I have 3 options :
>
> 1- `merge` my object back into the session 
> 2- use a non-expiring session
> 3- don't touch the column in the ORM/Session; have a second connection
> that issues updates via the core API
>
> does anyone have other ideas ?  or have others handled similar
> situations ?
>
>
>
> -- 
> 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
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

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

Reply via email to