Django raw sql query issue using class based view
vgkakade opened this issue · comments
def home(request): with connection.cursor() as cursor: os = '%(USN-%' sql = "select TITLE from xyz where LANG='en' and TITLE like '%(USN-%'" cursor.execute(sql) row = cursor.fetchone() print(row) return HttpResponse("<h1>I am Home</h1>")
This results correct output, however if I convert this into a class based view,
class Home(APIView): def get(self, request): with connection.cursor() as cursor: sql = "select TITLE from xyz where LANG='en' and TITLE like '%(USN-%'" cursor.execute(sql) row = cursor.fetchone() print(row) return JsonResponse(row[0], safe=False)
I get the error : django.db.utils.DatabaseError: ORA-00933: SQL command not properly ended
This is the issue tracker for the code.djangoproject.com website. Please see TicketClosingReasons/UseSupportChannels for ways to get help with Django usage.