不用连接池的MySQL连接方法 import MySQLdb conn= MySQLdb.connect(host='localhost',user='root',passwd='pwd',db='myDB',port=3306) cur=conn.cursor() SQL="select * from table1" r=cur.execute(SQL) r=cur.fetchall() c... Read More
posted @ 2017-05-14 14:22 zoro_robin Views(633) Comments(0) Diggs(0) Edit
python的MySQLdb库可以使用批量操作executemany,进行多行插入。 比如向user表(username,salt,pwd)插入数据,具体的sql语句如下: 之前使用execute方法循环写入数据,表字段多的时候,每秒有时只能写入几条,而executemany方法一次性全部提交,1w Read More
posted @ 2017-05-14 14:14 zoro_robin Views(3870) Comments(0) Diggs(0) Edit