P
P
pcdesign2016-02-15 11:57:12
Flask
pcdesign, 2016-02-15 11:57:12

How to get the last insert id in SQLAlchemy if the names of the id fields are different for the tables?

I know that you can just get the last inserted id like this:

me = User(nickname, email, passw)
    db.session.add(me)
    db.session.commit()
    print(me.id)


But what to do if in many tables the id field is not called id, but for example dd_id, or u_id, or bal_id, etc.
Manually writing for each case is somehow not a hunt.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-02-15
@pcdesign

stackoverflow.com/questions/6745189/how-do-i-get-t...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question