On Tue, Aug 16, 2011 at 1:16 PM, Dirk Makowski <dirk.makow...@googlemail.com
> wrote:

> P.S.
> In my first attempt, I used the ORM like this
>         sess = DbSession()
>         entity = sess.query(Role).filter(Role.id==id).one()
>         sess.delete(entity)
>         sess.flush()
>
> This had worked well. But this way the record first is selected before it
> is deleted, which I'd liked to eliminate.
>
>
Look at the delete() method of query.
http://www.sqlalchemy.org/docs/orm/query.html#sqlalchemy.orm.query.Query.delete

sess.query(Role).filter(Role.id==id).delete()

read the description of synchronize_session parameter to determine what is
needed in your application

-- 
Mike Conley

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