'Duplicated data in python 3

In my database the duplicates of data showing up. But this is not what i want. I want off every datatype 1 and not 2. this is my code:

for dim_cinema in processed_response:

# "Cinema" dimension
cinema = str(dim_cinema["cinema"])
cinema_location = str(dim_cinema["cinema_location"])

if cinema == None:
    cinema_location == None

# Check whether this record already exists in the dimension we created.
# We do this, because we don't have to insert it twice.
cursor.execute ("""
SELECT * FROM dim_cinema
WHERE cinema_name = '"""+cinema+"""'
AND cinema_location = '"""+cinema_location+""""'
""")

if cursor.rowcount == 0:
    # We don't have this combination in our dimension. Lets insert it!
    sql = """
    INSERT INTO dim_cinema (cinema_name, cinema_location)
    VALUES ('"""+cinema+"""', '"""+cinema_location+"""')
    """
    
    try:
        # Execute the SQL command and commit our changes to the database...
        cursor.execute(sql)
        print (cinema, cinema_location)
        db.commit()
        
    except:
        # Unless something goes wrong, in which case we do a rollback on our changes.
        db.rollback()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source