开发者

Python Mysql Request with variables

开发者 https://www.devze.com 2023-03-12 10:48 出处:网络
I have used python for a long time but I have trouble with a particular string-variable manipulation case

I have used python for a long time but I have trouble with a particular string-variable manipulation case

I want to do something like this:

##################################

开发者_StackOverflow中文版#sample
MYROW= 'ID_project'

result=curs.execute("""select %s FROM shotmanager_projects""",(MYROW))

#result=curs.execute("""select %s FROM shotmanager_projects""",('ID_sample')) 
# don t work too

###################################

And it doesnt work at all!

Why isn't % var not accepted in this case?


(x) is not a tuple with one element, it is a normal value. (x,) is a tuple with one element.


result = curs.execute("select %s FROM shotmanager_projects", (MYROW,))

0

精彩评论

暂无评论...
验证码 换一张
取 消