本日作業分

このコミットが含まれているのは:
2024-09-25 01:48:58 +09:00
コミット d8b83c8632
+36
ファイルの表示
@@ -172,6 +172,42 @@ class VideoDao:
videos.append (self._create_dto_from_row (row, with_relation_tables))
return videos
def upsert_all (
self,
videos: list[VideoDto],
with_relation_tables: bool = True,
) -> int:
with self.conn.cursor () as c:
for video in videos:
c.execute ("""
INSERT INTO
videos(
code,
title,
description,
uploaded_at,
deleted_at)
VALUES
(
%s,
%s,
%s,
%s,
%s)
ON DUPLICATE KEY UPDATE
code = VALUES(code),
title = VALUES(title),
description = VALUES(description),
uploaded_at = VALUES(uploaded_at),
deleted_at = VALUES(deleted_at)""", (
video.code,
video.title,
video.description,
video.uploaded_at,
video.deleted_at))
video.id_ = c.lastrowid
# TODO: with_relation_tables が True の場合,子テーブルも UPSERT すること
def _create_dto_from_row (
self,
row,