使用 CGI Python 将变量引入 SQL 语句
Bring in a variable into a SQL statement with CGI Python
我只想做一个更新语句并引入两个 cgi python 变量:inputMin 和 inputMax。
这是我的:
curInsert.execute("Update User set SetMinF = %d, SetMaxF = %d" .format(inputMin, inputMax))
引入变量的正确语法是什么? %d
? %s
? ?
?
尝试curInsert.execute("Update User set SetMinF = %s, SetMaxF = %s" % (inputMin, inputMax))
我想通了,这很愚蠢。我正在使用浮点数并需要 %f,所以它看起来像这样:
curInsert.execute("Update User set SetMinF = %f, SetMaxF = %f" % (inputMin, inputMax))
我只想做一个更新语句并引入两个 cgi python 变量:inputMin 和 inputMax。
这是我的:
curInsert.execute("Update User set SetMinF = %d, SetMaxF = %d" .format(inputMin, inputMax))
引入变量的正确语法是什么? %d
? %s
? ?
?
尝试curInsert.execute("Update User set SetMinF = %s, SetMaxF = %s" % (inputMin, inputMax))
我想通了,这很愚蠢。我正在使用浮点数并需要 %f,所以它看起来像这样:
curInsert.execute("Update User set SetMinF = %f, SetMaxF = %f" % (inputMin, inputMax))