I have a simple table in mysql with the following fields:
- id — Primary key, int, autoincrement
- name — varchar(50)
- description — varchar(256)
Using MySQLdb, a python module, I want to insert a name and description into the table, and get back the id.
In pseudocode:
db = MySQLdb.connection(...) queryString = 'INSERT into tablename (name, description) VALUES' % (a_name, a_desc);' db.execute(queryString); newID = ???
I think it might be
Edit by Original Poster
Turns out, in the version of MySQLdb that I am using (1.2.2) You would do the following:
I am leaving this as the correct answer, since it got me pointed in the right direction.