I have connected to database in python successfully but it is not saving the data I provide.Here is the code :
try:
connection = MySQLdb.connect(host="localhost",user="root",passwd="",db="traffic_alert")
except Exception as e:
print('Not connected')
cursor = connection.cursor()
cursor.execute("insert into data (main_status,extracted_info,time) values (%s,%s,%s)",[sentence,final_result,time])
print(sentence)
print(final_result)
print(time)
it can successfully print sentence, final_result and time but not saving them in database.sentence,final_result and time are less than 50 characters.I have created the database manually in mysql with these rows :
id -> auto_increment,pk
main_status -> varchar(255)
extracted_info -> varchar(255)
seen -> int(10),Null=True
time ->varchar(255)
tryindentation is off. Also, any error messages either on python or db side perhaps?