批量插入
使用db.session.execute()方法执行SQL语句,当需要批量插入SQL语句时可以使用以下方法:
sql = "insert into class_schedule(uid, class_address) values (:uid, :class_address)"
value = [{uid:xxx,class_address:xxxxxxx},
{uid:xxx,class_address:xxxxxxx},
{uid:xxx,class_address:xxxxxxx},
.........]
db.session.execute(sql, value)
如上即可批量插入
正常使用的SQL语句
sql = "insert into class_schedule(uid, week_time) values ('%s','%s')% (uid, week_time)"