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

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

问题描述

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

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天全站免登陆