相关疑难解决方法(0)

如何在django中运行普通的sql查询时获取字段名称

在我的一个django视图中,我使用普通的sql(不是orm)查询数据库并返回结果.

sql = "select * from foo_bar"
cursor = connection.cursor()
cursor.execute(sql)
rows = cursor.fetchall()
Run Code Online (Sandbox Code Playgroud)

我得到的数据很好,但不是列名.如何获取返回的结果集的字段名称?

python django

10
推荐指数
3
解决办法
1万
查看次数

标签 统计

django ×1

python ×1