tags:

views:

30

answers:

1

I made a procedure in mysql and i call it using python but it take an input and i need to pass the value of a variable in python to it but the mysql doesn't understand that it is a variable because the variable is not defined in it's list of fields .

for example for a code written in python :

variable = "someValue"
cursor.execute("call procedure1(variable);")

note the following is not a solution :

cursor.execute("call procedure1("someValue");")
A: 

you mean something like this?

cursor.execute("call procedure('%s');" % variable )
yedpodtrzitko
the procedure has an output variable and i tried the following but it give strange result :cursor.execute("call procedure('%s',@output1);" % variable )cursor.execute("select @output1;")data = cursor.fetchone()print datathe result is :('someValue',)
knowledge
my problem now is that it give me the output in the following format :('expectedResult',) and i need it to be just : expectedResult
knowledge
It seems you got list as result. Try access first member via brackets and index: data[0]
yedpodtrzitko