I have information about a car:
brand="bmw"
model = "h256"
miles = "22.35 mils"
year = 2017
price= "$22.35"
I want to save this information in mysql database. So if this information does not exist in the database, it is stored.
But I have a problem when inserting. I know that not exists should be used. But I do not know how to use not exists. Help me please.
The code I have in mind:
c.execute('INSERT INTO mydata VALUES("%s","%s","%s","%i","%s") IF NOT EXISTS (SELECT * FROM mydata)'%(brand,model,miles,year,price))
At the top, I wrote the code I wanted, but that code is wrong.
I have searched for this many times. But I did not find a clear answer. Help me please . for solving this problem
Thanks a lot