Display query-set results on a Django template without using a django model

31 views Asked by At

AttributeError at /Blog/mycustomsql

module 'django.http.request' has no attribute 'META'

Request Method: GET Request URL: http://127.0.0.1:8000/Blog/mycustomsql Django Version: 2.1.5 Exception Type: AttributeError Exception Value:

module 'django.http.request' has no attribute 'META'

Exception Location: C:\Users\c822208\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\context_processors.py in debug, line 40 Python Executable: C:\Users\c822208\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.3 Python Path:

['C:\cygwin64\home\c822208\django\hr', 'C:\Users\c822208\AppData\Local\Programs\Python\Python37\python37.zip', 'C:\Users\c822208\AppData\Local\Programs\Python\Python37\DLLs', 'C:\Users\c822208\AppData\Local\Programs\Python\Python37\lib', 'C:\Users\c822208\AppData\Local\Programs\Python\Python37', 'C:\Users\c822208\AppData\Local\Programs\Python\Python37\lib\site-packages']

Server time: Wed, 9 Oct 2019 08:58:49 +0000

def mycustomsql(self): 
    import cx_Oracle
    conn_string = cx_Oracle.connect('hr/[email protected]/xe')
    cursor1=conn_string.cursor()
    cursor2=conn_string.cursor()

    cursor1.execute("SELECT p.name,p.value FROM   v$parameter p  ORDER BY p.name")
    results1 = cursor1.fetchall()
    cursor2.execute("SELECT p.name,p.value FROM   v_param p  ORDER BY p.name")
    results2 = cursor2.fetchall()
    for index in range(0,len(results1)):
       if results2[index] == results1[index]:
          # print ('Found')
          continue
       rs= (results1[index],"   :   ",results2[index])
       # return HttpResponse(rs) -- this is giving me one row instead of 2
       context = {
        "object_list": rs
            }
       return render(request, "Blog/param.html", context)

 python python_tut/query.py
localhost/xe  -  ('shared_pool_size', '0') : localhost/xe  -  ('shared_pool_size', '5')
localhost/xe  -  ('streams_pool_size', '0') : localhost/xe  -  ('streams_pool_size', '8')
0

There are 0 answers