-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySql : call LAST_INSERT_ID() after insert to get the last generated id. #1011
Comments
|
@sgrif could you be so kind giving an example please? (I am interested in sqlite and postgre-sql). |
@vityafx In case you have not found a solution yet. in my db module I have
I use it as below
|
@mmrath sir do you have a sample to implement this get last_insert_id im new at diesel and rust itself it will be a big help |
@sgrif What's your recommended way of getting the ID of the last inserted record? |
@kevinmichaelchen There is no good solution for this on sqlite and mysql.
|
@weiznich The downsides of Generating the ID in Rust code seems fine if the primary key is a UUID. Overall, I think I'm leaning toward Postgres, since it has the |
@mmrath I would change
|
Setup
Versions
Feature Flags
Problem Description
After insert into a table with auto_incremented primary key, we need to get the generated id after the insert.
What are you trying to accomplish?
In PG the following works.
But we don't have anything similar for MySQL
What is the expected output?
Something like the above to work in MySQL
What is the actual output?
Are you seeing any additional errors?
Steps to reproduce
Checklist
The text was updated successfully, but these errors were encountered: