From 6535cbed7025696938ef6a9df7b694ec8a508390 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Thu, 10 Oct 2024 02:40:29 +0900 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E3=81=8A=E8=A9=A6=E3=81=97=E3=80=91Up?= =?UTF-8?q?sert=20=E6=99=82=E3=81=AB=20LAST=5FINSERT=5FID=20=E6=8C=87?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update_db.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/update_db.py b/update_db.py index e4d6914..0d2e75c 100644 --- a/update_db.py +++ b/update_db.py @@ -403,6 +403,7 @@ class VideoDao: %s, %s) ON DUPLICATE KEY UPDATE + id = LAST_INSERT_ID(id), code = VALUES(code), title = VALUES(title), description = VALUES(description), @@ -623,6 +624,7 @@ class VideoTagDao: %s, %s) ON DUPLICATE KEY UPDATE + id = LAST_INSERT_ID(id), video_id = VALUES(video_id), tag_id = VALUES(tag_id), tagged_at = VALUES(tagged_at), @@ -756,6 +758,7 @@ class TagDao: VALUES (%s) ON DUPLICATE KEY UPDATE + id = LAST_INSERT_ID(id), name = VALUES(name)""", (tag.name,))) tag.id_ = c.lastrowid @@ -837,11 +840,12 @@ class VideoHistoryDao: %s, %s) ON DUPLICATE KEY UPDATE - video_id, - fetched_at, - views_count""", (video_history.video_id, - video_history.fetched_at, - video_history.views_count))) + id = LAST_INSERT_ID(id), + video_id = VALUES(video_id), + fetched_at = VALUES(fetched_at), + views_count = VALUES(views_count)""", (video_history.video_id, + video_history.fetched_at, + video_history.views_count))) def upsert_all ( self, @@ -938,6 +942,7 @@ class CommentDao: %s, %s) ON DUPLICATE KEY UPDATE + id = LAST_INSERT_ID(id), video_id = VALUES(video_id), comment_no = VALUES(comment_no), user_id = VALUES(user_id),