0

I want to use stored procedure in python code like below.

import pyodbc
conn = pyodbc.connect('Trusted_Connection=yes', driver = '{SQL Server}',
                      server = 'ZAMAN\SQLEXPRESS', database = 'foy3') 

def InsertUser(studentID,name,surname,birth,address,telephone):
    cursor = conn.cursor()
    cursor.execute("exec InserttoDB studentID,name,surname,birth,address,telephone")
    rows = cursor.fetchall()

I have a problem below part of code. How can I send function parametters to DB with InserttoDB (stored procedure)

cursor.execute("exec InserttoDB studentID,name,surname,birth,address,telephone")

1 Answer 1

2

I am not sure what database you are using but I think this should do the job.

cursor.execute("call SP_YOUR_SP_NAME(params)")
Sign up to request clarification or add additional context in comments.

Comments

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.