From e13a0e0bc3e29d869bd3321377f4c04e1c3a78ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 30 Apr 2023 17:16:17 +0300 Subject: [PATCH] SyncDatabase: Add find_by_id method --- plextraktsync/db/SyncDatabase.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plextraktsync/db/SyncDatabase.py b/plextraktsync/db/SyncDatabase.py index 7f3d639c4a..aa18cede38 100644 --- a/plextraktsync/db/SyncDatabase.py +++ b/plextraktsync/db/SyncDatabase.py @@ -2,6 +2,8 @@ from typing import TYPE_CHECKING +from sqlmodel import Session, select + from plextraktsync.db.models.SyncRecord import SyncRecord if TYPE_CHECKING: @@ -14,6 +16,11 @@ class SyncDatabase: def __init__(self, engine: Engine): self.engine = engine + def find_by_id(self, media_id: int): + with Session(self.engine) as session: + statement = select(SyncRecord).where(SyncRecord.media_id == media_id) + return session.exec(statement).first() + def insert(self, record: SyncRecord): pass