1. 程式人生 > >django-sqlite執行原生sql

django-sqlite執行原生sql

sqlit cursor object from get ans color fetchall djang

from django.db import connection


question_obj = models.Questions.objects.get(pk=qid)

cursor = connection.cursor()
cursor.execute(question_obj.answer)
res = cursor.fetchall()  # 返回元組
for i in res:
    print(i, i[1])

django-sqlite執行原生sql