I want to write a piece of code where I want to import the files from a SQLite database and then check if there is already a record that has some same attributes and in that case I want to not run the part of my if statement.
for entry in entries:
if beer.name not in entries[3]:
print(f'New beer found: {beer.name}')
print(f'Beer price: {beer.price}')
beer.rating, beer.unt_id, beer.style = untappd_scraper(beer)
if beer.unt_id is not entry[4]:
if site == "Hopt":
c.execute("INSERT INTO beers VALUES (:a, :b, :c, :g, :e, :f)", {'a': beer.name, 'b': beer.style, 'c': beer.rating,'g': beer.unt_id, 'e': beer.price, 'f': ''})
# conn.commit()
elif site == "Beerdome":
c.execute(
"INSERT INTO beers VALUES (:a, :b, :c, :g, :e, :f)", {'a': beer.name, 'b': beer.style, 'c': beer.rating, 'g': beer.unt_id, 'e': '', 'f': beer.price})
# conn.commit()
conn.commit()
This does not seem to work, since the beer just keeps on being added, even tho its already multiple times in the list. So how can I change this code to make it work?
Aucun commentaire:
Enregistrer un commentaire