随笔分类 -  mysql

摘要:不用连接池的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... 阅读全文
posted @ 2017-05-14 14:22 zoro_robin 阅读(676) 评论(0) 推荐(0)
摘要:python的MySQLdb库可以使用批量操作executemany,进行多行插入。 比如向user表(username,salt,pwd)插入数据,具体的sql语句如下: 之前使用execute方法循环写入数据,表字段多的时候,每秒有时只能写入几条,而executemany方法一次性全部提交,1w 阅读全文
posted @ 2017-05-14 14:14 zoro_robin 阅读(3951) 评论(0) 推荐(0)