Search code examples
pythoncgimysql-python

Bring in a variable into a SQL statement with CGI Python


All I want to do is do an update statement and bring in two cgi python variables: inputMin, and inputMax.

Here's what I have:

curInsert.execute("Update User set SetMinF = %d, SetMaxF = %d" .format(inputMin, inputMax))    

What's the proper syntax to bring in a variable? %d? %s? ??


Solution

  • I figured it out, it was something dumb. I was using floats and needed %f, so it looks like this:

    curInsert.execute("Update User set SetMinF = %f, SetMaxF = %f" % (inputMin, inputMax))