you can check for a given identity in the session using the identity key
functions:
from sqlalchemy.orm.util import identity_key
key= identity_key(MyClass, someid)
object_already_in_session = key in session.identity_map
but usually people use session.merge(object) instead of session.add() to
Hi,
I create a certain number of objects in a loop, I check if each of the
objects is already stored in the session and if it is not I add it to
the session.
session = Session()
for item in items:
item1=create_item()
if not item1 in session:
session.add(item1)
session.commit()
The