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()
时间: 2024-10-29 19:10:12