Hello I am having a problem where the is NULL, is not working in my if statement. I am attempting to remove “None” from the code’s output, but neither is NULL or == “None” are working
Code
import mysql.connector
mydb = mysql.connector.connect(
host="100.0.0.1",
user="root",
password="",
database="data_logic"
)
mycursor = mydb.cursor()
subject = input("Enter your value: ")
vals = (subject,)
sql = "SELECT * FROM classez LEFT JOIN software ON FK_SOFT_ID = SOFT_ID LEFT JOIN text_books ON FK_BOOK_ID = BOOK_ID LEFT JOIN tools ON FK_TOOL_ID = TOOL_ID WHERE SUBJECT_NUM = %s"
mycursor.execute(sql,vals)
myresult = mycursor.fetchall()
print("\nThese are the results:\n")
for row in myresult:
if row is None:
print("")
else:
print(row)
Sample Output
1, 'Campbell Biology', 12, 'Pearson', 'Urry', 'Lisa', '9780135188743', 'E-book', 94.99, 'http://amazon.com/Campbell-Biology-2-download', 0, None, None, None, None, None, None, None)