0

我想在 python 代码中使用存储过程,如下所示。

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()

我在部分代码下面有问题。如何使用 InserttoDB(存储过程)将函数参数发送到 DB

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

1 回答 1

2

我不确定您使用的是什么数据库,但我认为这应该可以完成这项工作。

cursor.execute("call SP_YOUR_SP_NAME(params)")
于 2013-04-12T05:02:41.140 回答