如何在Django后端使用存储过程?

如何在Django后端使用存储过程?,django,stored-procedures,django-rest-framework,Django,Stored Procedures,Django Rest Framework,我已经在SSMS中为查询SELECT*FROM表创建了一个存储过程,现在我想创建一个Django API并对其进行测试。整个过程是什么 SQL存储过程中的我的脚本: USE [test] GO /****** Object: StoredProcedure [dbo].[spGetAll] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- =======================================

我已经在SSMS中为查询SELECT*FROM表创建了一个存储过程,现在我想创建一个Django API并对其进行测试。整个过程是什么

SQL存储过程中的我的脚本:

USE [test]
GO
/****** Object:  StoredProcedure [dbo].[spGetAll]     ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[spGetAll] 
    
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    SELECT * from app_comment
END
GO

要调用存储过程,请执行以下操作-

从django.db导入连接 def dictfetchallcursor: columns=[col[0]表示游标中的col.description] 返回[ dictzip列,行 对于cursor.fetchall中的行 ] 使用connection.cursor作为游标: cursor.callprocstored_过程[arg1、arg2、arg3] 数据=dictfetchallcursor 供参考