数据库
首页 > 数据库> > mysql executemany批量写入数据

mysql executemany批量写入数据

作者:互联网

if isinstance(item,MmzItem):
            data = {'xinxi':item['xinxi']}
            xinxia = data['xinxi']
            print(len(xinxia),type(xinxia))
            #print("ffffffffffffff",xinxi[0],xinxi[0][8])
            try:
                con.executemany('insert ignore into xi(zhi,gon,go,gon1,nian2,di2,xue2,jin2,rq2,w2z)values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',xinxia)
            except pymysql.Error as e:
                print(e)
                connect.rollback()
                connect.close()
                sys.exit(0)
            connect.commit()
            connect.close()
            #connect.commit()
            print("保存信息.........................")

 

标签:executemany,写入,xinxi,connect,mysql,print,close,xinxia,data
来源: https://www.cnblogs.com/xkdn/p/15484211.html