views:

26

answers:

1

http://www.sqlalchemy.org/docs/reference/orm/sessions.html

I don't see anything for updating an object that was just retrieved from the database using:

q = session.query(products)

for p in q:
     p.blah = 'hello'

     sesion.????
     session.commit()
+4  A: 

That line p.blah = 'hello' is updating the property (column) blah of the object p.

That's the power of object relational mapping in newer languages. Enjoy.

Triptych
Also get familiar with the "Unit of Work" concept (http://martinfowler.com/eaaCatalog/unitOfWork.html). The session is a "Unit Of Work" in SQLAlchemy (and ORMs in general), which is tracking the status of the "registered" (loaded or newly added) objects automatically.
van