用多存储实现Python OLAP多维数据集
我在两个不同的数据库中有两个表,如下所示。我想使用 Python OLAP多维数据集以获得下面提到的输出用多存储实现Python OLAP多维数据集,python,olap,olap-cube,Python,Olap,Olap Cube,我在两个不同的数据库中有两个表,如下所示。我想使用 Python OLAP多维数据集以获得下面提到的输出 DB1 Table name: Customer_details id name 1 abc 2 xyz DB 2 Table Name : Bills id Customer_id amount 1 1 500 2 1 600 3 2 300 Output
DB1
Table name: Customer_details
id name
1 abc
2 xyz
DB 2
Table Name : Bills
id Customer_id amount
1 1 500
2 1 600
3 2 300
Output
Name Amount
abc 1100
xyz 300
下面是我用来解决这个问题的一些代码:
{
"dimensions": [
{
"name":"customer_details",
"levels":[
{
"name":"customer",
"label":"Customer",
"attributes": ["id","name"]
}
]
}
],
"cubes": [
{
"name": "bills",
"dimensions": ["customer_details"],
"measures": [
{"name":"amount", "label":"Total"}
],
"aggregates": [
{
"name": "total",
"function": "sum",
"measure": "amount"
}
],
"joins":[
{"master":"bills.customer_id", "detail":"customer_details.id"}
],
"mappings": {
"name": "customer_details.name"
}
}
]
}
workspace = Workspace()
workspace.register_store("store1", "sql", url="postgresql://...")
workspace.register_store("store2", "sql", url="postgresql://...")
workspace.import_model("model.json"), store="store1", namespace="default")
workspace.import_model("model.json"), store="store2", namespace="default")
browser = workspace.browser("bills")
cubeData = browser.aggregate(drilldown=["customer_details"])
我得到的错误是没有这样的表customer\u details实际上您在那里写了表名为
Table name: Customer_details
以及您在model.json中编写的维度
.."name":"customer_details", ...
大小写可以解决您的问题 实际上您已经在那里写下了表名是
Table name: Customer_details
以及您在model.json中编写的维度
.."name":"customer_details", ...
大小写可以解决您的问题