django orm sql 语句
1放数据,存在则修改,不存在则创建
REPLACE INTO home_goodstable (user,goods_id,goods_img,goods_title,monitor_time) VALUES('123', '123456','123','123','2020-10-10');
https://blog.csdn.net/sj349781478/article/details/81433213
通过检查主键字段,判断是否存在,需设置唯一主键。
2.检查数据是否存在 不存在返回N
select ifnull((select user from home_goodstable where goods_id=%s and on_monitor=%s and monitor_time=%s limit 1),"N")
3.更新语句
update home_goodstable set on_monitor=%s where goods_id=%s',['on',goods_id,]

浙公网安备 33010602011771号