SQLAlchemy - Update if object has a PK -


Is there any way to inform SQLAlchemy that if all the objects are PK present in a graph, should they update?

Edit: By PK I mean PK value

I'm a bit confused with the use of your "graph", if you mean the table, then I think you need something like this:

  pk_exists_query = session.query (MyTable) Filter (MyTable.id! = None). For all recordings in Pk_exists_query (): record.foo = #whatever  

If you want to update the records for the same value which is much easier and you (MyTable.id! = None) .update ({'foo': 'bar'})

  session.query (MyTable) .filter (MyTable.id! = None) / Pre> 

Comments