Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cursors and loops
#2
Never mind. Trial and error got me there eventually. :)

Still, if anyone has any useful tips about my coding that would be nice.

Here is the working version:
mycursor = mydb.cursor()
for dfct in defects:
	if dfct == 0:
		break
	# first get the data_id of the latest revision
	sql = "SELECT * FROM table_def_int_data WHERE defect_id='" + str(dfct) + "' AND revision = (SELECT MAX(revision) from table_def_int_data where defect_id='" + str(dfct) + "')"
	mycursor.execute(sql)
	myresult = mycursor.fetchone()
	sql = "SELECT * FROM table_def_int_data WHERE defect_id='" + str(dfct) + "' AND data_id = " + str(myresult[0])
	mycursor.execute(sql)
	myresult = mycursor.fetchone()
	print(myresult)
mycursor.close()
Reply


Messages In This Thread
Cursors and loops - by Clark - Sep-26-2018, 03:41 AM
RE: Cursors and loops - by Clark - Sep-26-2018, 04:45 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020