# Path: hakoblog/model/entry.py
# class Entry:
#     def __init__(self, id, blog_id, title, body, created, modified):
#         self.id = id
#         self.blog_id = blog_id
#         self.title = title
#         self.body = body
#         self.created = created
#         self.modified = modified


from hakoblog.model.entry import Entry


class EntryLoader:
    @classmethod
    def find_by_id(cls, db, entry_id):
        with db.cursor() as cursor:
            cursor.execute(
                """
                SELECT id, blog_id, title, body, created, modified
                FROM entry
                WHERE id = %s
                LIMIT 1
                """,
                (entry_id,),
            )
            row = cursor.fetchone()

            if row is None:
                return None


# Path: hakoblog/model/entry.py
# class Entry:
#     def __init__(self, id, blog_id, title, body, created, modified):
#         self.id = id
#         self.blog_id = blog_id
#         self.title = title
#         self.body = body
#         self.created = created
#         self.modified = modified


# Path: hakoblog/loader/entry.py
from hakoblog.model.entry import Entry



class EntryLoader:
    @classmethod
    def find_by_id(cls, db, entry_id):
        with db.cursor() as cursor:
            cursor.execute(
                """
                SELECT id, blog_id, title, body, created, modified
                FROM entry
                WHERE id = %s
                LIMIT 1
                """,
                (entry_id,),
            )
            row = cursor.fetchone()

            if row is None:
                return None


        return Entry(**row)