# 批量插入数据
    def addinsertall(val):
        db = sql.init()
        cur = db.cursor()
        val = [(
            11,
            22,
            33,
            44,
            55,
            66
        )]
        vsql = "INSERT INTO oct_itemprice (tid, price, couponprice, tkrates, type, time) VALUES (%s, %s, %s, %s, %s, %s)"
        try:
            cur.executemany(vsql, val)
            db.commit()
        except Exception as e:
            sql.log('批量插入异常', e)
            db.rollback()
        finally:
            cur.close()
            db.close()
  
        sql.log('本次批量插入成功' + str(cur.rowcount) + '条数据')
        return cur.rowcount
最后修改于:2021-10-24 12:02
文章链接: https://oct.cn/view/109
版权声明: 本站所有文章除特别声明外。转载请注明来自 十月笔记