working on pyramid with sqlalchemy:
newjob_obj=Job(name=name,job_propery=job_property,sizeX=sizeX,
sizeY=sizeY,quantity=quantity,timeline=timeline,
description=description,remarks=remarks,
client_id=client_id,created_by=created_by,status=status
)
new_job=session.add(newjob_obj)
print('Return newJob value %s\n' % new_job)
Here new_job is printing as None
.
add function of session returns object or not. Please help.
To answer your question in the comment of @mark's answer - in order to receive your "inserted ID" after the commit:
session.add(newjob_obj)
session.commit()
You should refresh the inserted object with:
session.refresh(newjob_obj)
print newjob_obj.id
Hope it helps ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With