Possible Duplicate:
In Python, after I INSERT Into mysqldb, how do I get the “id”?
How to fetch the primary key post insertion into foo, so that I can insert the foreign key reference in other tables.
import MySQLdb
cursor = mysqlconn.cursor()
cursor.execute("""INSERT INTO foo (value) VALUES (%s)""", (value))
prod_mysql_conn.commit()