Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
151cddf3
Commit
151cddf3
authored
May 12, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format
parent
a35255b4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
29 deletions
+28
-29
olapy/core/mdx/executor/execute.py
olapy/core/mdx/executor/execute.py
+7
-6
olapy/core/mdx/tools/config_file_parser.py
olapy/core/mdx/tools/config_file_parser.py
+15
-21
olapy/core/mdx/tools/connection.py
olapy/core/mdx/tools/connection.py
+4
-2
olapy/core/mdx/tools/models.py
olapy/core/mdx/tools/models.py
+2
-0
No files found.
olapy/core/mdx/executor/execute.py
View file @
151cddf3
...
...
@@ -311,15 +311,15 @@ class MdxEngine:
if
dimension_name
in
tables
.
keys
():
df
=
tables
[
dimension_name
]
else
:
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
dimension_and_key
.
split
(
'.'
)[
0
]),
db
.
connection
)
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
dimension_and_key
.
split
(
'.'
)[
0
]),
db
.
connection
)
fusion
=
fusion
.
merge
(
df
,
left_on
=
fact_key
,
right_on
=
dimension_and_key
.
split
(
'.'
)[
1
])
return
fusion
[[
column
for
column
in
all_columns
if
'id'
!=
column
[
-
2
:]]]
return
fusion
[[
column
for
column
in
all_columns
if
'id'
!=
column
[
-
2
:]
]]
def
_construct_star_schema_csv_files
(
self
,
cube_name
):
"""
...
...
@@ -379,7 +379,8 @@ class MdxEngine:
fusion
=
None
config_file_parser
=
ConfigParser
(
self
.
cube_path
)
if
config_file_parser
.
config_file_exist
(
client_type
if
config_file_parser
.
config_file_exist
(
client_type
)
and
cube_name
in
config_file_parser
.
get_cubes_names
():
for
cubes
in
config_file_parser
.
construct_cubes
(
client_type
):
# TODO cubes.source == 'csv'
...
...
olapy/core/mdx/tools/config_file_parser.py
View file @
151cddf3
...
...
@@ -215,7 +215,10 @@ class ConfigParser:
"""
# TODO one config file (I will try to merge dimensions between them in web part)
def
__init__
(
self
,
cube_path
,
file_name
=
'cubes-config.xml'
,
web_config_file_name
=
'web_cube_config.xml'
):
def
__init__
(
self
,
cube_path
,
file_name
=
'cubes-config.xml'
,
web_config_file_name
=
'web_cube_config.xml'
):
"""
:param cube_path: path to cube (csv folders)
...
...
@@ -225,14 +228,15 @@ class ConfigParser:
self
.
file_name
=
file_name
self
.
web_config_file_name
=
web_config_file_name
def
config_file_exist
(
self
,
client_type
=
'excel'
):
def
config_file_exist
(
self
,
client_type
=
'excel'
):
"""
Check whether the config file exists or not.
:return: True | False
"""
if
client_type
==
'web'
:
return
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
cube_path
,
self
.
web_config_file_name
))
return
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
cube_path
,
self
.
web_config_file_name
))
return
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
cube_path
,
self
.
file_name
))
def
xmla_authentication
(
self
):
...
...
@@ -284,8 +288,7 @@ class ConfigParser:
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
keys
=
{
key
.
text
:
key
.
attrib
[
'ref'
]
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
},
measures
=
[
mes
.
text
...
...
@@ -331,27 +334,21 @@ class ConfigParser:
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
keys
=
{
key
.
text
:
key
.
attrib
[
'ref'
]
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
},
measures
=
[
mes
.
text
for
mes
in
xml_facts
.
findall
(
'measures/name'
)
mes
.
text
for
mes
in
xml_facts
.
findall
(
'measures/name'
)
])
for
xml_facts
in
tree
.
xpath
(
'/cubes/cube/facts'
)
]
tables
=
[
Table
(
name
=
xml_column
.
attrib
[
'name'
],
columns
=
xml_column
.
find
(
'columns'
).
text
.
split
(
','
),
columns
=
xml_column
.
find
(
'columns'
).
text
.
split
(
','
),
new_names
=
{
new_col
.
attrib
[
'old_column_name'
]
:
new_col
.
text
new_col
.
attrib
[
'old_column_name'
]:
new_col
.
text
for
new_col
in
xml_column
.
findall
(
'new_name'
)
}
)
for
xml_column
in
tree
.
xpath
(
'/cubes/cube/tables/table'
)
})
for
xml_column
in
tree
.
xpath
(
'/cubes/cube/tables/table'
)
]
return
[
...
...
@@ -359,15 +356,12 @@ class ConfigParser:
name
=
xml_cube
.
find
(
'name'
).
text
,
source
=
xml_cube
.
find
(
'source'
).
text
,
facts
=
facts
,
tables
=
tables
)
for
xml_cube
in
tree
.
xpath
(
'/cubes/cube'
)
tables
=
tables
)
for
xml_cube
in
tree
.
xpath
(
'/cubes/cube'
)
]
# except:
# raise ('Bad configuration in the configuration file')
def
construct_cubes
(
self
,
client_type
=
'excel'
):
def
construct_cubes
(
self
,
client_type
=
'excel'
):
"""
Construct cube (with it dimensions) and facts from the config file.
:param client_type: excel | web
...
...
olapy/core/mdx/tools/connection.py
View file @
151cddf3
...
...
@@ -5,16 +5,18 @@ USERNAME = 'postgres'
PASSWORD
=
'root'
HOST
=
'localhost'
class
MyDB
(
object
):
"""Connect to sql database (postgres only right now)."""
def
__init__
(
self
,
username
=
USERNAME
,
password
=
PASSWORD
,
db
=
None
,
host
=
HOST
):
if
db
is
None
:
self
.
connection
=
pg
.
connect
(
"user={0} password={1} host='{2}'"
.
format
(
username
,
password
,
host
))
self
.
connection
=
pg
.
connect
(
"user={0} password={1} host='{2}'"
.
format
(
username
,
password
,
host
))
else
:
try
:
self
.
connection
=
pg
.
connect
(
...
...
olapy/core/mdx/tools/models.py
View file @
151cddf3
...
...
@@ -37,6 +37,7 @@ class Dimension:
def
__str__
(
self
):
return
str
(
self
.
__dict__
)
class
Cube
:
"""Cube class used to encapsulate config file attributes."""
...
...
@@ -52,6 +53,7 @@ class Cube:
def
__str__
(
self
):
return
str
(
self
.
__dict__
)
class
Table
:
"""Column class used to encapsulate config file attributes for web client."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment