SQL Quesstion
PreviousPage 2 of 2

Tom Holden@ve3meo
374 Posts
#11 · 2020-05-12, 1:30 pm
Quote from Tom Holden on 2020-05-12, 1:30 pmI'm sure it's a Python programming question which is kinda outside the scope of this forum and certainly outside my limited sphere of competency. My only suggestion is to bring the sql2 expression inside the FOR loop which increments step so that it is sure to be expanded with that value.
step = 0 sql1 = "SELECT * FROM tl_link WHERE tl_name_key = 2 ORDER BY tl_entry_seq" cursor1 = connection.cursor() cursor2 = connection.cursor() for row in cursor1.execute(sql1): sql2 = "UPDATE tl_link SET tl_entry_seq = " + str(step) + " WHERE tl_name_key = 2" print("Step" , step, sql2) cursor2.execute(sql2) step = step + 10 # or maybe this goes right after the start of the FOR loop ...
I'm sure it's a Python programming question which is kinda outside the scope of this forum and certainly outside my limited sphere of competency. My only suggestion is to bring the sql2 expression inside the FOR loop which increments step so that it is sure to be expanded with that value.
step = 0 sql1 = "SELECT * FROM tl_link WHERE tl_name_key = 2 ORDER BY tl_entry_seq" cursor1 = connection.cursor() cursor2 = connection.cursor() for row in cursor1.execute(sql1): sql2 = "UPDATE tl_link SET tl_entry_seq = " + str(step) + " WHERE tl_name_key = 2" print("Step" , step, sql2) cursor2.execute(sql2) step = step + 10 # or maybe this goes right after the start of the FOR loop ...
Click for thumbs down.0Click for thumbs up.0
PreviousPage 2 of 2