Can someone help me out, this code is not inserting in my database yet its not giving any error,
- Code: Select all
import MySQLdb
connect=MySQLdb.Connect('localhost','root','','company')
cursor=connect.cursor()
def insertValues():
sql="INSERT INTO `company`.`employee` (`id`, `firstname`, `lastname`, `age`, `gender`, `income`) VALUES ('', 'Caroline', 'Njeri', '22', 'F', '7000')"
try:
cursor.execute(sql)
print "The employee has been inserted successfully"
except MySQLdb.Error, e:
print "There is an error ", e
connect.rollback
insertValues();
connect.close()