#!/usr/bin/python  
#edit www.jb200.com
# import 
mysql module  
import 
MySQLdb  
  
# get user input  
name = raw_input("Please enter a name: ")  
  
# connect  
db = MySQLdb.connect(host="localhost", user="nobody", passwd="nobody", db="qestar", unix_socket="/tmp/mysql.sock")  
  
# create a cursor  
cursor = db.cursor()  
  
# execute SQL statement  
cursor.execute("INSERT INTO test (nama) VALUES (%s)", name)  
  
# get ID of last inserted record  
print "ID of inserted record is ", int(cursor.lastrowid)