I'm using this below in views.py to get app
from django.db import connection
def test(request):
cursor = connection.cursor()
sql = """
SELECT x , n
from table1 limit 10
"""
cursor.execute(sql)
rows = cursor.fetchall()
# df1 = pd.read_sql_query(sql,cursor) <==> not working )
# df1.columns = cursor.keys() <==> not working )
return render(request, 'app/test.html',{ "row" : rows,})
I am able to print row and got a list of something like this below in test.html
row((x1,yvalue1),(x2,yvalue2) , .... ))
But what I'm trying to do is to get all data with its column name that I fetched and put into dataframe , hopefully to use something like this below :