简体   繁体   English

如何将mysql查询转换为django orm

[英]How to convert mysql query to django orm

I'm trying to execute this query, it's working fine in MySQL workbench, but It's not working in python shell.我正在尝试执行此查询,它在 MySQL 工作台中运行良好,但在 python shell 中不起作用。 在此处输入图像描述

And I have to export that result in an Excel sheet.我必须将该结果导出到 Excel 表中。

As de error suggests the SELECT clause must contain the primary key in order to be able to build the ORM object. By default, the primary key is a column named pk.由于 de error 建议 SELECT 子句必须包含主键才能构建 ORM object。默认情况下,主键是一个名为 pk 的列。 I advise using "SELECT *" in this case if possible, maybe the "AS" could give problems too.如果可能的话,我建议在这种情况下使用“SELECT *”,也许“AS”也会带来问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM