任何Python OLAP / MDX ORM引擎? [英] Any Python OLAP/MDX ORM engines?

查看:399
本文介绍了任何Python OLAP / MDX ORM引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MDX / OLAP的新手,我想知道是否有类似于支持OLAP的Python的Django ORM类似的ORM。

I'm new to the MDX/OLAP and I'm wondering if there is any ORM similar like Django ORM for Python that would support OLAP.

一个Python / Django开发人员,如果会有一些与Django有一定程度的集成,我将会更加了解更多关于它的信息。

I'm a Python/Django developer and if there would be something that would have some level of integration with Django I would be much interested in learning more about it.

推荐答案

Django有一些即将发布的OLAP功能。

Django has some OLAP features that are nearing release.

阅读 http://www.eflorenzano.com/blog/post/secrets-django-orm/

http://doughellmann.com /2007/12/30/using-raw-sql-in-django.html ,也

如果您在第一个地方,则一维结果可以具有以下形式。

If you have a proper star schema design in the first place, then one-dimensional results can have the following form.

from myapp.models import SomeFact
from collections import defaultdict

facts = SomeFact.objects.filter( dimension1__attribute=this, dimension2__attribute=that )
myAggregates = defaultdict( int )
for row in facts:
    myAggregates[row.dimension3__attribute] += row.someMeasure

如果要创建二维总结,你必须做如下的事情。

If you want to create a two-dimensional summary, you have to do something like the following.

facts = SomeFact.objects.filter( dimension1__attribute=this, dimension2__attribute=that )
myAggregates = defaultdict( int )
for row in facts:
    key = ( row.dimension3__attribute, row.dimension4__attribute )
    myAggregates[key] += row.someMeasure

要计算多个SUM和COUNT,而不需要执行此操作。

To compute multiple SUM's and COUNT's and what-not, you have to do something like this.

class MyAgg( object ):
    def __init__( self ):
        self.count = 0
        self.thisSum= 0
        self.thatSum= 0

myAggregates= defaultdict( MyAgg )
for row in facts:
    myAggregates[row.dimension3__attr].count += 1
    myAggregates[row.dimension3__attr].thisSum += row.this
    myAggregates[row.dimension3__attr].thatSum += row.that

这 - 首先是脸红 - - 似乎效率低下你正在拖动事实表,返回大量的行,然后您在应用程序中进行聚合。

This -- at first blush -- seems inefficient. You're trolling through the fact table returning lots of rows which you are then aggregating in your application.

在某些情况下,这可能会更快 RDBMS的本机sum / group_by。为什么?您正在使用简单的映射,而不是RDBMS经常为此使用更复杂的基于排序的分组操作。是的,你得到很多行但是你做得更少了。

In some cases, this may be faster than the RDBMS's native sum/group_by. Why? You're using a simple mapping, not the more complex sort-based grouping operation that the RDBMS often has to use for this. Yes, you're getting a lot of rows; but you're doing less to get them.

这个缺点是它不像我们想要的那么声明。它的优点是纯粹的Django ORM。

This has the disadvantage that it's not so declarative as we'd like. It has the advantage that it's pure Django ORM.

这篇关于任何Python OLAP / MDX ORM引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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