import pymssql DBHOST = '127.0.0.1' DBUSER = 'sa' DBPASS = 'test' DBNAME = 'test' def retrieve(): try: db = pymssql.connect(DBHOST, DBUSER, DBPASS, DBNAME) cur = db.cursor() cur.callproc('stored procedure name',('test0008','test','test','test','2020-10-14')) # cur.execute("exec P_ChangeLastStatus @BARCODE='test0004',@ACTIVITY='test',@COMMENT='test',@DETAIL_ACTIVITY='test',@CREATE_TIME='2020-10-14'") cur.nextset() #获取返回值 results = cur.fetchall() #获取返回值
db.commit()
cur.close() d
b.close()
print(results)
except pymssql.Error as e: print('数据库连接失败'+str(e)) return "error"
retrieve()