LMSouq
database Open

How do I get the "id" after INSERT into MySQL database with Python?

TI
TIMEX
1 month ago
3 views
Problem Description
I execute an INSERT INTO statement cursor.execute("INSERT INTO mytable(height) VALUES(%s)",(height)) and I want to get the primary key. My table has 2 columns: id primary, auto increment height this is the other column. How do I get the "id", after I just inserted this?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base