Get Primary Key From Sqlalchemy Before Commit The Object
I have been using sqlalchemy with postgres and dont know how to solve the issue bellow. I want to get the value of primary key before commit to DB. I have a class called process th
Solution 1:
You can use flush()
method, the changes aren't persisted permanently to disk, until you call commit()
:
p = process(proc_num=45)
db.session.flush(p)
p = process.query.filter_by(proc_num=45)
p.proc_id
# finally you can call commit
db.session.commit()
Post a Comment for "Get Primary Key From Sqlalchemy Before Commit The Object"