Browse Source

ログ出力追加

feature/query
みてるぞ 1 month ago
parent
commit
980dd0ac60
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      update_db.py

+ 22
- 0
update_db.py View File

@@ -324,6 +324,7 @@ class VideoDao:
id = %s id = %s
ORDER BY ORDER BY
id""", (video_id,)) id""", (video_id,))
print (c._executed)
row = cast (VideoRow | None, c.fetchone ()) row = cast (VideoRow | None, c.fetchone ())
if row is None: if row is None:
return None return None
@@ -346,6 +347,7 @@ class VideoDao:
videos videos
ORDER BY ORDER BY
id""") id""")
print (c._executed)
videos: list[VideoDto] = [] videos: list[VideoDto] = []
for row in cast (list[VideoRow], c.fetchall ()): for row in cast (list[VideoRow], c.fetchall ()):
videos.append (self._create_dto_from_row (row, with_relation_tables)) videos.append (self._create_dto_from_row (row, with_relation_tables))
@@ -367,6 +369,7 @@ class VideoDao:
videos videos
WHERE WHERE
deleted_at IS NULL""") deleted_at IS NULL""")
print (c._executed)
videos: list[VideoDto] = [] videos: list[VideoDto] = []
for row in cast (list[VideoRow], c.fetchall ()): for row in cast (list[VideoRow], c.fetchall ()):
videos.append (self._create_dto_from_row (row, False)) videos.append (self._create_dto_from_row (row, False))
@@ -411,6 +414,7 @@ class VideoDao:
video.description, video.description,
video.uploaded_at, video.uploaded_at,
deleted_at)) deleted_at))
print (c._executed)
video.id_ = c.lastrowid video.id_ = c.lastrowid
if with_relation_tables: if with_relation_tables:
if video.video_tags is not None: if video.video_tags is not None:
@@ -443,6 +447,7 @@ class VideoDao:
deleted_at = %%s deleted_at = %%s
WHERE WHERE
id IN (%s)""" % ', '.join (['%s'] * len (video_ids)), (at, *video_ids)) id IN (%s)""" % ', '.join (['%s'] * len (video_ids)), (at, *video_ids))
print (c._executed)


def _create_dto_from_row ( def _create_dto_from_row (
self, self,
@@ -507,6 +512,7 @@ class VideoTagDao:
video_id = %s video_id = %s
ORDER BY ORDER BY
id""", (video_id,)) id""", (video_id,))
print (c._executed)
video_tags: list[VideoTagDto] = [] video_tags: list[VideoTagDto] = []
for row in cast (list[VideoTagRow], c.fetchall ()): for row in cast (list[VideoTagRow], c.fetchall ()):
video_tags.append (self._create_dto_from_row (row, with_relation_tables)) video_tags.append (self._create_dto_from_row (row, with_relation_tables))
@@ -532,6 +538,7 @@ class VideoTagDao:
AND (untagged_at IS NULL) AND (untagged_at IS NULL)
ORDER BY ORDER BY
id""", (video_id,)) id""", (video_id,))
print (c._executed)
video_tags: list[VideoTagDto] = [] video_tags: list[VideoTagDto] = []
for row in cast (list[VideoTagRow], c.fetchall ()): for row in cast (list[VideoTagRow], c.fetchall ()):
video_tags.append (self._create_dto_from_row (row, with_relation_tables)) video_tags.append (self._create_dto_from_row (row, with_relation_tables))
@@ -556,6 +563,7 @@ class VideoTagDao:
WHERE WHERE
video_id = %s video_id = %s
AND tag_id = %s""", (video_id, tag_id)) AND tag_id = %s""", (video_id, tag_id))
print (c._executed)
row = cast (VideoTagRow, c.fetchone ()) row = cast (VideoTagRow, c.fetchone ())
if row is None: if row is None:
return None return None
@@ -588,6 +596,7 @@ class VideoTagDao:
%s, %s,
%s)""", (video_tag.video_id, video_tag.tag_id, %s)""", (video_tag.video_id, video_tag.tag_id,
video_tag.tagged_at, untagged_at)) video_tag.tagged_at, untagged_at))
print (c._executed)
video_tag.id_ = c.lastrowid video_tag.id_ = c.lastrowid
if with_relation_tables: if with_relation_tables:
if video_tag.video is not None: if video_tag.video is not None:
@@ -630,6 +639,7 @@ class VideoTagDao:
video_tag.tag_id, video_tag.tag_id,
video_tag.tagged_at, video_tag.tagged_at,
untagged_at)) untagged_at))
print (c._executed)
video_tag.id_ = c.lastrowid video_tag.id_ = c.lastrowid
if with_relation_tables: if with_relation_tables:
if video_tag.video is not None: if video_tag.video is not None:
@@ -662,6 +672,7 @@ class VideoTagDao:
WHERE WHERE
video_id = %%s video_id = %%s
AND tag_id IN (%s)""" % ', '.join (['%s'] * len (tag_ids)), (now, video_id, *tag_ids)) AND tag_id IN (%s)""" % ', '.join (['%s'] * len (tag_ids)), (now, video_id, *tag_ids))
print (c._executed)


def _create_dto_from_row ( def _create_dto_from_row (
self, self,
@@ -710,6 +721,7 @@ class TagDao:
tags tags
WHERE WHERE
id = %s""", (tag_id,)) id = %s""", (tag_id,))
print (c._executed)
row = cast (TagRow | None, c.fetchone ()) row = cast (TagRow | None, c.fetchone ())
if row is None: if row is None:
return None return None
@@ -728,6 +740,7 @@ class TagDao:
tags tags
WHERE WHERE
name = %s""", (tag_name,)) name = %s""", (tag_name,))
print (c._executed)
row = cast (TagRow | None, c.fetchone ()) row = cast (TagRow | None, c.fetchone ())
if row is None: if row is None:
return None return None
@@ -743,6 +756,7 @@ class TagDao:
tags(name) tags(name)
VALUES VALUES
(%s)""", (tag.name,)) (%s)""", (tag.name,))
print (c._executed)
tag.id_ = c.lastrowid tag.id_ = c.lastrowid


def upsert ( def upsert (
@@ -758,6 +772,7 @@ class TagDao:
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
id = LAST_INSERT_ID(id), id = LAST_INSERT_ID(id),
name = VALUES(name)""", (tag.name,)) name = VALUES(name)""", (tag.name,))
print (c._executed)
tag.id_ = c.lastrowid tag.id_ = c.lastrowid


def _create_dto_from_row ( def _create_dto_from_row (
@@ -797,6 +812,7 @@ class VideoHistoryDao:
video_histories video_histories
WHERE WHERE
video_id = %s""", (video_id,)) video_id = %s""", (video_id,))
print (c._executed)
video_histories: list[VideoHistoryDto] = [] video_histories: list[VideoHistoryDto] = []
for row in cast (list[VideoHistoryRow], c.fetchall ()): for row in cast (list[VideoHistoryRow], c.fetchall ()):
video_histories.append (self._create_dto_from_row (row, with_relation_tables)) video_histories.append (self._create_dto_from_row (row, with_relation_tables))
@@ -820,6 +836,7 @@ class VideoHistoryDao:
%s)""", (video_history.video_id, %s)""", (video_history.video_id,
video_history.fetched_at, video_history.fetched_at,
video_history.views_count)) video_history.views_count))
print (c._executed)


def upsert ( def upsert (
self, self,
@@ -844,6 +861,7 @@ class VideoHistoryDao:
views_count = VALUES(views_count)""", (video_history.video_id, views_count = VALUES(views_count)""", (video_history.video_id,
video_history.fetched_at, video_history.fetched_at,
video_history.views_count)) video_history.views_count))
print (c._executed)


def upsert_all ( def upsert_all (
self, self,
@@ -902,6 +920,7 @@ class CommentDao:
comments comments
WHERE WHERE
video_id = %s""", (video_id,)) video_id = %s""", (video_id,))
print (c._executed)
comments: list[CommentDto] = [] comments: list[CommentDto] = []
for row in cast (list[CommentRow], c.fetchall ()): for row in cast (list[CommentRow], c.fetchall ()):
comments.append (self._create_dto_from_row (row, with_relation_tables)) comments.append (self._create_dto_from_row (row, with_relation_tables))
@@ -954,6 +973,7 @@ class CommentDao:
comment.posted_at, comment.posted_at,
comment.nico_count, comment.nico_count,
vpos_ms)) vpos_ms))
print (c._executed)


def upsert_all ( def upsert_all (
self, self,
@@ -1015,6 +1035,7 @@ class UserDao:
users users
WHERE WHERE
code = %s""", (user_code,)) code = %s""", (user_code,))
print (c._executed)
row = cast (UserRow | None, c.fetchone ()) row = cast (UserRow | None, c.fetchone ())
if row is None: if row is None:
return None return None
@@ -1030,6 +1051,7 @@ class UserDao:
users(code) users(code)
VALUES VALUES
(%s)""", (user.code,)) (%s)""", (user.code,))
print (c.execute)
user.id_ = c.lastrowid user.id_ = c.lastrowid


def _create_dto_from_row ( def _create_dto_from_row (


Loading…
Cancel
Save