Below is a portion of code that is supposed to add the names of authors to a table.
def create_author_table():
cursor.execute("CREATE TABLE IF NOT EXISTS author(name VARCHAR(100),PRIMARY KEY (name))")
if authorFound == 1:
cursor.execute("INSERT author (name) VALUES (?)", (aname, ))
conn.commit()
The rest of my code is irrelevant to the problem I think, so I didn't include it.
I have a very long list of author names, and every time a name is read in, I try to write it to the author table. However, some of the names are duplicates, which is a problem since name is a primary key so I can't insert duplicates. Does anyone know a query that only inserts names that don't already exist in the table? I am using python 2.7 and sqlite through jupyter notebook in case anyone needs to know.
I realize that there are many similar questions already on this site, but I have looked through them and I haven't had any luck. This is my first time working in python so I'm generally inexperienced.