Skip to content
Advertisement

How can I input a python variable into a stored procedure?

I need to query a SQL Db using a specific value from my python script, here is what i have so far:

For this i get an error syaing DATA1 is an invalid data type, am i writing the sqL query right? Note that var_num is pulled earlier in the script and is not shown here.

EDIT: I have also tried the following method and still no luck:

conn = pyodbc.connect(”)

However this still doesn’t work and returns the fault:

can anyone tell me what i am doing wrong, i do not want to set var_num as the column name??

Advertisement

Answer

As illustrated in the pyodbc Wiki, something like this should work:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement