使用Python接口查询OLAP Mondrian(MDX,XMLA)?

发布于 2024-09-24 13:44:46 字数 2800 浏览 1 评论 0 原文

实际上我正在使用 R + Python 和 RPY2 来操作数据和 ggplot 来创建漂亮的图形..我在 PostgreSQL 数据库中有一些数据,我正在使用 psycopg2 来查询数据。

我正在开始一篇论文,将来我需要一个 OLAP 多维数据集 来存储我的(非常大)模拟数据:多维度、聚合查询等。Python

(我想要Python + R,没有jpivot或Java中的其他一些仪表板)和OLAP引擎(如蒙德里安?我在谷歌上搜索任何解决方案,但没有找到任何东西。

我已经简要评估了 SQLAlchemy 和 Django-ORM,但它们没有 MDX 或 XML/A 接口来查询 OLAP 服务器(Mondrian 或其他)...

是否可以编写查询在 MDX 中,使用 psycopg + ODBC,查询我的 OLAP 服务器,OLAP 服务器从我的模拟数据中给我一个答案(Python 对象上没有映射,但对我来说没问题)?

更新1:

为什么我需要围绕 OLAP + Mondrian 技术进行搜索?

因为拉瓦尔大学(GeoSoa 部门 + Thierry Badard)编写了 OLAP 的空间扩展:SOLAP,并在 Mondrian 中将其实现为 GeoMondrian。 这让我感兴趣,因为我正在研究基于空间多代理的模拟(〜=地理模拟)。

GeoSoa 部门创建了一个基于 Ajax 的组件,用于与 GeoMondrian 进行通信和可视化空间数据:SOLAPLAYERS,它可以通过其 Xlma servlet 查询 Mondrian 服务器。

问题:大数据操作可能很慢,需要互联网或 Apache 2。简单地说,它只是为了可视化数据或地图...就我而言,我需要原始数据来使用 R 进行自己的数据操作+图形:空间分析、回归分析、rank-tail 等。在这里,SOLAP 帮助我为后面的复杂 R 分析准备数据。

为什么选择 Python?

1 - 通过 Web 访问空间数据 -

我正在尝试使用一个“酷”的 Python 框架,例如 GeoDjangoMapFish:GIS 中的大社区,开源,使用 GeoAlchemy 操作空间查询/数据,包括使用 JavaScript 扩展进行可视化和< a href="http://en.wikipedia.org/wiki/OpenLayers" rel="noreferrer">OpenLayers 等

2 - 本地访问 GIS 中的空间数据 -

我想在 QGIS 中创建一个插件(开源 GIS)来访问和可视化数据,以及 QGIS 插件和 API = Python。

3 - 数据自动分析 -

用户或科学家使用网格计算运行模拟,并选择他们想要对此数据运行的自动分析(R + ggplot2 + MDX 查询)。我的目标是创建模拟的综合报告(图形、表格数据等)。

因此,模拟之后,数据进入 OLAP/SOLAP 立方体,许多 Python 脚本(由用户创建)使用 MDX 获取数据,使用 R + RPY2 操作数据,并在 doku-wiki 或其他平台上为科学家编写和生成很酷的输出社区平台。

问题?

1 - Olap4j,Mondrian 与外部组件通信的 API 核心,是 Java 制造的:/

2 - SOLAPLAYERS 使用 Ajax 访问数据,对于用户来说速度太慢我。

3 - SQLAlchemy 和 GeoAlchemy 没有与多维数据库 (OLAP) 的驱动程序连接。

* 解决方案? *

1 - Py4j 使用 Python 访问 olap4j 中的 Java 对象或 Java 集合?编写自己的函数来访问 Java 映射集合? =>危险而且不太容易?...

2 - XLMA 与 Ajax Mondrian 服务器?太慢了。

3 - 将我自己的 py 连接器写入 OLAP Mondrian ? =>哎哟。我想,这是一条艰难的路。

我应该怎么办?

Actually I'm using R + Python with RPY2 to manipulate data and ggplot to create beautiful graphics.. I have some data in a PostgreSQL database, and I'm using psycopg2 to query data.

I'm starting a thesis, and in the future I need an OLAP cube to store my (very big) simulation data: multiple dimension, aggregation query, etc.

Is there any best or standard practice for interfacing between Python (and I want Python + R, no jpivot or some other dashboard in Java) and an OLAP engine like Mondrian? I searched on Google for any solution, and didn't I find anything.

I've briefly evaluated SQLAlchemy, and Django-ORM, but they have no MDX or XML/A interface to query an OLAP server (Mondrian or other) ...

Is it possible to write a query in MDX and, with psycopg + ODBC, query my OLAP server, and the OLAP server giving me an answer from my simulation data (no mapping on Python object, but it's OK for me)?

Update 1 :

Why do I need to search around OLAP + Mondrian technology ?

Because University of Laval (GeoSoa departements + Thierry Badard) wrote a spatial extension to OLAP: SOLAP, and implemented this in Mondrian as GeoMondrian.
That interest me because I'm working on spatial multi agent based simulation ( ~= geosimulation).

The GeoSoa departement created an Ajax based component to communicate and visualize spatial data with GeoMondrian: SOLAPLAYERS, which can query a Mondrian server by its Xlma servlet.

Problem : probably slow in big data manipulation, need Internet or Apache 2. Briefly, it's only to visualize data or map ... In my case, I need raw data to make my own data manipulation + graphics with R: spatial analysis, regression analysis, rank-tail, etc. Here, SOLAP help me to prepare data for this later complex R analysis.

Why Python?

1 - Web access to spatial data -

I'm trying to use a "cool" Python framework, like GeoDjango or MapFish: big community in GIS, open-source, use GeoAlchemy to manipulate spatial query/data, include visualisation with JavaScript extensions and OpenLayers, etc.

2 - Local access to spatial data in GIS -

I want to create a plugin in QGIS (open source GIS) to access and visualize data, and QGIS plugin and API = Python.

3 - Automatic analysis of data -

A user or scientist runs a simulation with grid computing and choose automatic analysis (R + ggplot2 + MDX query) they want to run on this data. My goal here is to create a synthetic report of the simulation (graphic, tabular data, etc.).

So, after simulation, data go to OLAP/SOLAP cube, and many Python scripts (created by the user) get data with MDX, manipulate data with R + RPY2, and write and produce cool output for the scientist on doku-wiki or another community-platform.

Problem?

1 - Olap4j, the API core of Mondrian to communicate with an external component, is Java-made :/

2 - SOLAPLAYERS uses Ajax to access data, too slow for me.

3 - SQLAlchemy and GeoAlchemy have no driver connection to a multidimensional database (OLAP).

* Solution? *

1 - Py4j to access Java object or Java collection in olap4j with Python? Write my own function to access the Java mapped collection? => dangerous and not very easy?...

2 - XLMA with Ajax Mondrian server? It is too slow.

3 - Write my own py-connector to OLAP Mondrian ? => Ouch. It's an hard way, I think.

What should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月流歌 2024-10-01 13:44:46

我不懂 python,但我是 mondrian/olap4j 的作者。

如果您可以使用 py4j 访问 olap4j,那就太好了。如果没有,一定要考虑 XMLA。它可能没有你想象的那么慢(除非python的XML解析很慢)。最大的问题是构建 SOAP 请求和理解响应的复杂性。

朱利安

I don't know python, but I am author of mondrian/olap4j.

If you can use py4j to access olap4j, great. If not, definitely consider XMLA. It may not be as slow as you think (unless python's XML parsing is slow). The biggest problem is the complexity of constructing SOAP requests and understanding the responses.

Julian

烟─花易冷 2024-10-01 13:44:46

如您所知,Mondrian 是一个在 MySQL 等数据库之上用 Java 编写的完整 OLAP 引擎。所以如果我理解你的问题,你想使用 Mondrian 并想知道如何将它与 Python 连接。

我使用打包在 .jar 中的 Mondrian 在命令行上处理 MDX 查询并发回 JSON。 Python直接在命令行中调用它。

import commands
result = commands.getoutput('java -jar Mondrian_cli.jar -q 
select NON EMPTY Crossjoin({[Measures].[Store Sales]}, 
Crossjoin([Time].[1997].Children, [Store].[All Stores].Children)) ON COLUMNS, 
[Product].[All Products].Children ON ROWS from [Sales]') 

对于服务器使用,我将其打包在 servlet 中,并使用 ajax 发送 MDX。 ajax 调用并不是很大的开销,这就是为什么我认为不需要耦合 Python 和 Java 而只是与 Mondrian 服务器通信。

As you know, Mondrian is a complete OLAP engine written in java on top of a database like MySQL. So if I understand your question, you want to use Mondrian and wonder how to interface it with Python.

I use Mondrian packaged in a .jar to process MDX queries on command line and send back a JSON. Python calls it directly in the command line.

import commands
result = commands.getoutput('java -jar Mondrian_cli.jar -q 
select NON EMPTY Crossjoin({[Measures].[Store Sales]}, 
Crossjoin([Time].[1997].Children, [Store].[All Stores].Children)) ON COLUMNS, 
[Product].[All Products].Children ON ROWS from [Sales]') 

And for server use, I package it in a servlet and I send MDX with ajax. The ajax calls are not a big overhead and that's why I don't see the need of coupling Python and Java rather than just communicating with the Mondrian server.

爱格式化 2024-10-01 13:44:46

对于非常大的数据立方体存储和检索,HDF5 存储效果相当好(h5py 或 Python 接口的 PyTables)。然后,您的应用程序可以在具有 HDF5 数据库本地副本的计算机上运行,​​也可以制作临时服务器解决方案(仍然使用 Python)。

我一直在根据需要设计混合 SQL/HDF5 存储策略,并且它们的性能相当不错。

如果确实需要 MDX 查询语言:

  • 作为 ORM(之前stackoverflow 上的答案)

  • cubulus(尽管只实现了 MDX 的一个子集)

  • 将您选择的 OLAP 作为单独的服务器运行并与它通过一个特别的接口(甚至可能是通过 http 的 XML)。

For very large data cubes storage and retrieval, HDF5 storage is working rather well (h5py or PyTables for a Python interface). Your application can then either run on a machine with a local copy of the HDF5 database or make an ad-hoc server solution (still in Python).

I have been designing hybrid SQL / HDF5 storage strategies when needed, and they are performing rather well.

If really need the MDX query language:

  • as an ORM (earlier answers on stackoverflow)

  • cubulus (although only a subset of MDX is implemented)

  • run the OLAP of your choice as a separate server and communicate with it through an ad-hoc interface (might even be XML through http).

稳稳的幸福 2024-10-01 13:44:46

为了完成一点,我刚刚发现了这个 python 包来访问 XMLA 服务器:www。它表示正在与 Mondrian、icCube、MSAS 合作。

To complete a bit, I've just discovered this python package to access XMLA server : www. It says it's working with Mondrian, icCube, MSAS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文