I am having trouble in getting the results returned by the stored procedure which is called by sqlalchemy, I am seeing that even though stored procedure is returning an integer sql alcehmy. Result set is set to None, which is causing some issues, can someone tell me whats going on?
CREATE PROCEDURE [SYSDATA].[getCertificateInstallStatus]
@DVSystemName [varchar](max)
AS
BEGIN
declare @system_state int = (SELECT state FROM SYSDATA.certificate where DVSystemName = @DVSystemName)
if @system_state is not NULL
Return @system_state
Return 0
END
Now executing this stored procedure:
DECLARE @return_value int
EXEC @return_value = [SYSDATA].[getCertificateInstallStatus]
@DVSystemName = N'UATDSG'
SELECT 'Return Value' = @return_value
GO
Calling this procedure returns:
Return Value
0
Python error trace:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/SQLAlchemy-1.2.7-py3.6-macosx-10.9-x86_64.egg/sqlalchemy/engine/result.py", line 1067, in _fetchone_impl return self.cursor.fetchone() AttributeError: 'NoneType' object has no attribute 'fetchone'
During handling of the above exception, another exception occurred: ...... File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/SQLAlchemy-1.2.7-py3.6-macosx-10.9-x86_64.egg/sqlalchemy/engine/result.py", line 1089, in _non_result "This result object does not return rows. " sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically.