NSS-Day-Cohort-58 / rare-python-server-striking-dragons

rare-python-server-striking-dragons created by GitHub Classroom
0 stars 0 forks source link

Created get_single_tag function in tag_requests.py #67

Closed jsa-codes closed 2 years ago

jsa-codes commented 2 years ago

Created the following function:

def get_single_tag(id):
    with sqlite3.connect("./db.sqlite3") as conn:

        conn.row_factory = sqlite3.Row
        db_cursor = conn.cursor()

        db_cursor.execute(
            """
        SELECT
          t.id,
          t.label
        FROM Tag t
        WHERE t.id = ?
          """,
            (id,),
        )

        data = db_cursor.fetchone()

        tag = Tag(data['id'], data['label'])

        return tag.__dict__
jsa-codes commented 2 years ago

Fixed the SELECT statements in both Tags and Posts