import socket,MySQLdb,sys,random,time
conn=MySQLdb.connect('127.0.0.1','root','1','asterisk')
cursor=conn.cursor()
cursor.execute('insert into test(a) values(1)')
print "a"
cursor.close()
conn.close()


在调用execute()之后,close()之前要调用一下提交:


conn.commit()