1

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:

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

#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?

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

Don't Work: MYROW = 'title' result=curs.execute("""select %s FROM shotmanager_projects""",(MYROW)) 'code' return: (('title'),),(('title'),),(('title'),),(('title'),)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.