Organizational Research By

Surprising Reserch Topic

how do you safely and efficiently get the row id after an insert with mysql usin using -'python,mysql'


how do you safely and efficiently get the row id after an insert with mysql usin  using -'python,mysql'

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 = ???

    
asked Sep 7, 2015 by rajesh
0 votes
10 views



Related Hot Questions



Government Jobs Opening


...