1

genre1, genre2, genre3 has data being retrieved from select fields on my web page. When I select two genres (two fields) it adds the movie perfectly fine. But when I select all three genres (all fields) it gives me an error.

It just doesnt work when theres (genre1,genre2,genre3) It does work when its (genre1,genre3)..but I need all three ofcourse

"Error binding parameter 0 - probably unsupported type."

for name in (genre1, genre2, genre3):
  if name != "":

    genreInfo = db.execute(
        """
        SELECT Genre_ID
        FROM Genres
        WHERE Genre = ?; 
        """,
        (name,)
        )
    selectedGenre = genreInfo.fetchone()[0]

    db.execute(
        """
        INSERT INTO Movie_Genre (Movie_ID, Genre_ID)
        VALUES (?,?)
        """,
        (MovieID, int(selectedGenre),)
        )
    db.commit()
  else:
    pass
    flash("Movie Added!")
    return render_template('admin.html', user_name=user_name, genre=genre)
3
  • Please edit the question to include the full traceback and the value causing the error. You have two queries with parameters; we have no way of knowing which one fails. Commented Jun 7, 2016 at 15:14
  • Thats all I have, i did not know what was causing the error either. Moving 'db.commit()' outside the for loop fixed the issue.. Commented Jun 8, 2016 at 1:51
  • Python gives you a traceback. The title of this question is the last line. We need everything before it, too. Commented Jun 8, 2016 at 1:52

1 Answer 1

2

Okay.. So I moved "db.commit()" so that its outside the for loop and it worked.. I do not know why so if anyone would like to explain.. please feel free to!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.