import pymysql conn = pymysql.connect(host=‘localhost‘, port=3306,user=‘root‘,passwd=‘root‘,db=‘DeliveryAddress‘,charset=‘UTF8‘) cur = conn.cursor() cur.execute("INSERT INTO `ProvinceCityCountyTown` VALUES (‘3‘, ‘0‘, ‘上海‘)") conn.commit()#这里是用conn提交的,很让人不解,为什么不用cur提交呢?害得我baidu都没找到例子, cur.close() conn.close()
原文地址:http://my.oschina.net/deanzhao/blog/317760