I am getting error return below trying to execute Stored Procedured in Django view using SQL Server database with mssql-django.
Can you help me to find the solution, below I leave the code of the view and the connection to SQL Server.
def arquive1(request):
cursor = connection.cursor()
try:
cursor.execute("EXEC dbo.suspensos")
result = cursor.fetchall()
finally:
cursor.close()
context = {
'result': result
}
return render(request, 'test1.html', context)
DATABASES = {
'default': {
'ENGINE': 'mssql',
'NAME': 'XXXXXXXX',
'USER': 'xxxxx',
'PASSWORD': 'xxxxxx',
'HOST': 'xxxxxxxx',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
}
}
ERROR RETURNED:
OperationalError at /app
near "EXEC": syntax error
Request Method: GET
Request URL: http://xxxxxxxx/app
Django Version: 4.0
Exception Type: OperationalError
Exception Value:
near "EXEC": syntax error
Yes, that's exactly what I want you to help me with