0

I have defined a function to add rows to a MYSQL database. But it keeps giving an error saying-

_mysql_connector.MySQLInterfaceError: Column count doesn't match value count at row 1

During handling of the above exception, another exception occurred:
mysql.connector.errors.DataError: 1136 (21S01): Column count doesn't match value count at row 1

Here's my code

#add new records
def add_records():
    db = msq.connect(host = "localhost", user = "root", passwd = "abhi2004", database = "Movie_Sites")
    cur = db.cursor()
    count = int(input("Enter number of records to enter: "))
    for i in range(count):
        name = input("Enter name of movie: ")
        actors = input("Enter a comma separated list of actors: ")
        genre = input("Enter genre: ")
        ratings = float(input("Enter movie ratings: "))
        sql = "insert into movies(Movie,Actors,Genre,Ratings) values ({},{},{},{})".format(name,actors,genre,ratings)
        cur.execute(sql)
        db.commit()
    db.close()
    print("Records added")

How do I fix it? What's going wrong?

0 Answers0