Sep-26-2018, 03:41 AM
Hello all
Very new Python user here, so be gentle.
If there is a better way to do what I am trying to do (self evident from the code), please let me know.
My problem is that the program starts to go through the loop once. If I uncomment out the mycursor.close, it fails on the mycursor.close line. If I leave it commented then it fails on the second iteration of the loopo at the assignment of mycursor = mydb.cursor().
TIA
Very new Python user here, so be gentle.
If there is a better way to do what I am trying to do (self evident from the code), please let me know.
My problem is that the program starts to go through the loop once. If I uncomment out the mycursor.close, it fails on the mycursor.close line. If I leave it commented then it fails on the second iteration of the loopo at the assignment of mycursor = mydb.cursor().
for dfct in defects: if dfct == 0: break sql = "SELECT * FROM table_def_int_data WHERE defect_id='" + str(dfct) + "'" mycursor = mydb.cursor() mycursor.execute(sql) myresult = mycursor.fetchone() print(myresult) # mycursor.close()Please let me know what I am doing incorrect here. (Probably many things ha ha)
TIA