简体   繁体   中英

Call sql server stored procedure in Python

I have a stored procedure

exec dbo.update_candidate "ur", 0

where "ur",0 -is paramtrs

But if it is called in the program, it does not work:

params = list()
name1 = "ur"
voises1 = "1"
params1=(name1,voises1)
cursor.execute("{CALL update_candidate (?,?)}",params1)

In Pyton

   params2=(name1,'5')
   cursor.execute("exec dbo.update_candidate %s,%s" % params2)
   cursor.commit()

In SQLServer:

exec dbo.update_candidate "Hadjr", 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM