diff --git a/__pycache__/models.cpython-312.pyc b/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000..c05f319 Binary files /dev/null and b/__pycache__/models.cpython-312.pyc differ diff --git a/__pycache__/my_eloquent.cpython-312.pyc b/__pycache__/my_eloquent.cpython-312.pyc new file mode 100644 index 0000000..a1977ed Binary files /dev/null and b/__pycache__/my_eloquent.cpython-312.pyc differ diff --git a/__pycache__/update_db.cpython-312.pyc b/__pycache__/update_db.cpython-312.pyc new file mode 100644 index 0000000..2e6d0c6 Binary files /dev/null and b/__pycache__/update_db.cpython-312.pyc differ diff --git a/my_eloquent.py b/my_eloquent.py index a21efa8..afcf22a 100644 --- a/my_eloquent.py +++ b/my_eloquent.py @@ -1,3 +1,10 @@ +# pylint: disable = missing-class-docstring +# pylint: disable = missing-function-docstring + +""" +みてるぞ式魔改造(言ふほどか?)版 Eloquent +""" + import eloquent @@ -6,6 +13,8 @@ class DatabaseManager (eloquent.DatabaseManager): class Model (eloquent.Model): + id: int + def upsert ( self, *args: str, @@ -16,5 +25,7 @@ class Model (eloquent.Model): row = q.first () if row is not None: self.id = row.id - self._Model__exists = True # pylint: disable = protected-access + # pylint: disable = invalid-name + # pylint: disable = attribute-defined-outside-init + self._Model__exists = True self.save () diff --git a/update_db.py b/update_db.py index 4e8f25b..f80c31d 100644 --- a/update_db.py +++ b/update_db.py @@ -59,7 +59,7 @@ def update_tables ( video_history.video_id = video.id video_history.fetched_at = now video_history.views_count = datum['viewCounter'] - video_history.save () + video_history.upsert () video_tags = [video_tag for video_tag in video.video_tags if video_tag.untagged_at is not None] tag: Tag | None