conn = MySQLdb.connect(host=IP,user='john',passwd='ab2nng',db='mydb')
cursor = conn.cursor()
#this works.
cursor.execute("select * from crawl_log")
res = cursor.fetchall()
print res
#this doesn't work.
cursor.execute("insert into crawl_log(k, v) values(%s, %s)", ('test','test'))
How do I know why it didn’t work? No errors print, nothing.
By default it will start a transaction which will need to be committed after any statement that affects change to the data. Have you tried
conn.commit()after your insert?