Django是否支持普通表表达式? [英] Does Django natively support common table expressions?

查看:119
本文介绍了Django是否支持普通表表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了澄清我的问题,我想知道是否可以在访问CTE功能时习惯使用Django ORM。我想我可以通过编写原始SQL语句来使用CTE,但是使用ORM语法糖来绕过手写编码SQL语句的能力是Django的原始呼吁之一。

To clarify my question I would like to know if it is possible to idiomatically use the Django ORM whilst accessing CTE features. I imagine I could use CTE by writing raw SQL statements but the ability to use the ORM 'syntactic sugar' to bypass hand coding SQL statements was one of the original appeals of Django.

推荐答案

Django不直接支持CTE,因为这些都不是所有数据库的常见(MySQL不支持)。有一些软件包可以扩展Django的ORM来支持CTE的功能。其中之一是 django-cte-trees 。请注意,它只支持PostgreSQL。

Django doesn't support CTEs directly as these are not common to all databases (MySQL doesn't support it). There are packages that extend the capability of Django's ORM to support CTEs. One of these is django-cte-trees. Note that it only supports PostgreSQL.

这篇关于Django是否支持普通表表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆