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 create_tag function in tag_requests.py #70

Closed jsa-codes closed 2 years ago

jsa-codes commented 2 years ago

Created the following code

def create_tag(new_tag):
  with sqlite3.connect("./db.sqlite3") as conn:

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

        db_cursor.execute(
          """
        INSERT INTO TAGS
          (label)
        VALUES
          ( ? );
          """,
          (
            new_tag["label"]
          ),
        )

        id = db_cursor.lastrowid

        new_tag["id"] = id

  return new_tag