Hi,

This question is specific to Pylons and SQLAlchemy.
Hi all,

I have a mapped class (I am using SQLAlchemy's ORM), called Person. I
have a method on a pylons controller to delete a Person record from
the table that the Person class is mapped to. I am using the "id"
column (int, primary key) of the person table to delete this person
record.

 I find myself doing something like this:

        def deletePerson(self):
                person_id = int(request.GET["personId"])
                p = Session.query(Person).filter_by(id=person_id).first()
                if p:
                        Session.delete(p)
                        Session.commit()
                return redirect_to(action="list")

Is it normal, when using sqlalchemy, to have to select the Person
object first, then delete it? I would rather not hit the database for
the select, and then again for the delete. I realize I could probably
do this if I bypassed SQLAlchemy's ORM and used it's SQL expression
language, but I would rather not.

Thanks,
goon12

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to