我正在尝试向表中插入信息。但是我遇到了这个问题:
IntegrityError: UNIQUE constraint failed: my_films.title_id.
我不明白为什么,因为我没有ID,需要重复。你能帮我吗?
我的代码:
cur.execute("""CREATE TABLE my_films (
title_id INT,
title TEXT,
premiered INT,
rating REAL,
PRIMARY KEY (title_id))""")
con.commit()
films = [(1, 'Birds of Prey', 2020, 9),
(2, 'The Avengers', 2012, 10),
(3, 'Love Rosie', 2014, 7,6),
(4, 'Me Before You', 2016, 7,2)]
cur.executemany("INSERT INTO my_films VALUES (?, ?, ?, ?)", films)
con.commit()