Python Forum
which column of sql table is equal to a variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
which column of sql table is equal to a variable
#6
But you are trying to get rows with id = "f1", not rows with id = "789" - you have no variable substitution/expansion in your select string. So you are getting the correct response (unless you have row with id "f1" in your table ... ). 

Either format/construct your select string with your variable - you can do something like:
select_string = 'select * from bla where id = "{}";'.format(f1)
or use (and thats better solution, if its available) a variable substitution provided by a database connection - its usually something like:
cur.execute("select * from bla where id = ?", (f1,))
exact syntax might vary according to the database used.
Reply


Messages In This Thread
RE: which column of sql table is equal to a variable - by zivoni - Mar-14-2017, 02:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Column headers not aligning properly with table kenwatts275 3 3,563 Jul-13-2020, 12:53 AM
Last Post: menator01
  updating a field of sql table from a variable gray 1 3,574 Mar-19-2017, 06:38 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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