So I want to compare the input value with my database value. IF the input value is the same value as the database, I want to print(inputvalue). But if it's not the same, I want to print("Data Does Not Exist")
So I've tried this code :
cur = connection.cursor()
query = """ SELECT * FROM `foo` """
cur.execute(query)
result = cur.fetchall()
inputvalue = input("Input= ")
for x in result:
if inputvalue not in x:
print("Data Does Not Exist")
else:
print(inputvalue)
and this is the output:
inputvalue= 1728192
Data Does Not Exist
Data Does Not Exist
Data Does Not Exist
Data Does Not Exist
1728192
Data Does Not Exist
Data Does Not Exist
Data Does Not Exist
I expect the output is
Inputvalue= 1728192
Data Does Not Exist
If the Data Does Not Exist, And this output:
Inputvalue= 1728192
1728192
If the Data Exist
Any answer would be appreciated!