我正在使用 Django 原始 sql 查询使用连接和别名从数据库中获取数据 我的查询:
SELECT DISTINCT
A.entity_id AS entity_id,
A.email AS email,
A.catquizid AS style_quiz_score,
A.catquizquesans AS style_quiz_answer,
A.created_at AS date_joined,
A.is_active AS is_active,
B.attribute_id AS attribute_id,
B.value AS info
FROM
customer_entity AS A INNER JOIN customer_entity_varchar AS B
ON A.entity_id=B.entity_id WHERE B.attribute_id LIMIT 2
我正在获取这样的结果:
row = cursor.fetchall()
当我返回HttpResponse
一行时,它会显示正确的结果,但如果我返回HttpResponse(row['entity_id'])
,则会显示错误Sorry, an error occurred.
所以请告诉我如何row
使用他的别名访问数组。