def create_user_items(db: Session, mouse_events, user, events_dict):
mouse_events = json.loads(mouse_events)
db.execute(
models.Sessions.__table__.insert(),
[{"user_id": user, "x_coordinate": event["x_cor"], "y_coordinate": event["y_cor"],
"event_id": events_dict.get(event['event']), "event_time": event["event_time"],
"x_resolution": event["x_res"],
"y_resolution": event["y_res"]} for event in mouse_events]
)
db.commit()
标签:sqlalchemy,批量,python,db,events,user,id,mouse,event
From: https://www.cnblogs.com/guowenrui/p/17798705.html