def Creatsafe(ware,goods,db):
time = data.get_time()
Goods_num = len(goods)
for a in range(len(ware)):
houseId = ware[a][0]
c = sqlNum # 每一万条执行一次,否则速度会慢
minnum = math.floor(Goods_num / c)
for k in range(minnum + 1):
if k < minnum:
num = c
else:
num = Goods_num - k * c
txt=""
for r in range(k*c, k*c + num):
safetyStockId = data.id_str(2)
goodsId = goods[r][0]
shipperId = goods[r][1]
txt = txt+f"('{safetyStockId}', '{houseId}', '{shipperId}','{goodsId}', '1', '10.000000',"
f"'{creatID}', '{creatName}', '{time}', NULL, NULL, NULL),"
txt=txt[:-1]
sql=f"INSERT INTO base_safetystock (`safetyStockId`, `houseId`, `shipperId`, `goodsId`, "
f"`goodsForm`, `safetyStockNum`, `createorId`, `createName`, `createTime`, `updaterId`, `updateName`, `updateTime`)VALUES"+txt
db.execute_Insert(sql)
print(f"第{a+1}/{len(ware)}个仓库 安全库存 新建完成")
return 0
python执行的时候会报错:
数据库execute_Insert发生错误|Mysql Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
但是实际又是执行成功了,就很神奇,是我的sql语句写的有问题么?语法上真的没有看出有啥错误。
最后
以上就是眼睛大冰淇淋最近收集整理的关于Mysql Error 1064,python操作插入mysql数据库,报错但是插入成功的全部内容,更多相关Mysql内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复