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:
...
@@ -311,15 +311,15 @@ class MdxEngine:
if
dimension_name
in
tables
.
keys
():
if
dimension_name
in
tables
.
keys
():
df
=
tables
[
dimension_name
]
df
=
tables
[
dimension_name
]
else
:
else
:
df
=
psql
.
read_sql_query
(
df
=
psql
.
read_sql_query
(
"SELECT * FROM {0}"
.
format
(
"SELECT * FROM {0}"
.
format
(
dimension_and_key
.
split
(
'.'
)[
0
]),
dimension_and_key
.
split
(
'.'
)[
0
]),
db
.
connection
)
db
.
connection
)
fusion
=
fusion
.
merge
(
fusion
=
fusion
.
merge
(
df
,
left_on
=
fact_key
,
right_on
=
dimension_and_key
.
split
(
'.'
)[
1
])
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
):
def
_construct_star_schema_csv_files
(
self
,
cube_name
):
"""
"""
...
@@ -379,7 +379,8 @@ class MdxEngine:
...
@@ -379,7 +379,8 @@ class MdxEngine:
fusion
=
None
fusion
=
None
config_file_parser
=
ConfigParser
(
self
.
cube_path
)
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
():
)
and
cube_name
in
config_file_parser
.
get_cubes_names
():
for
cubes
in
config_file_parser
.
construct_cubes
(
client_type
):
for
cubes
in
config_file_parser
.
construct_cubes
(
client_type
):
# TODO cubes.source == 'csv'
# TODO cubes.source == 'csv'
...
...
olapy/core/mdx/tools/config_file_parser.py
View file @
151cddf3
...
@@ -215,7 +215,10 @@ class ConfigParser:
...
@@ -215,7 +215,10 @@ class ConfigParser:
"""
"""
# TODO one config file (I will try to merge dimensions between them in web part)
# 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)
:param cube_path: path to cube (csv folders)
...
@@ -225,14 +228,15 @@ class ConfigParser:
...
@@ -225,14 +228,15 @@ class ConfigParser:
self
.
file_name
=
file_name
self
.
file_name
=
file_name
self
.
web_config_file_name
=
web_config_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.
Check whether the config file exists or not.
:return: True | False
:return: True | False
"""
"""
if
client_type
==
'web'
:
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
))
return
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
cube_path
,
self
.
file_name
))
def
xmla_authentication
(
self
):
def
xmla_authentication
(
self
):
...
@@ -284,8 +288,7 @@ class ConfigParser:
...
@@ -284,8 +288,7 @@ class ConfigParser:
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
keys
=
{
keys
=
{
key
.
text
:
key
.
attrib
[
'ref'
]
key
.
text
:
key
.
attrib
[
'ref'
]
for
key
in
xml_facts
.
findall
(
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
'keys/column_name'
)
},
},
measures
=
[
measures
=
[
mes
.
text
mes
.
text
...
@@ -331,27 +334,21 @@ class ConfigParser:
...
@@ -331,27 +334,21 @@ class ConfigParser:
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
table_name
=
xml_facts
.
find
(
'table_name'
).
text
,
keys
=
{
keys
=
{
key
.
text
:
key
.
attrib
[
'ref'
]
key
.
text
:
key
.
attrib
[
'ref'
]
for
key
in
xml_facts
.
findall
(
for
key
in
xml_facts
.
findall
(
'keys/column_name'
)
'keys/column_name'
)
},
},
measures
=
[
measures
=
[
mes
.
text
mes
.
text
for
mes
in
xml_facts
.
findall
(
'measures/name'
)
for
mes
in
xml_facts
.
findall
(
'measures/name'
)
])
for
xml_facts
in
tree
.
xpath
(
'/cubes/cube/facts'
)
])
for
xml_facts
in
tree
.
xpath
(
'/cubes/cube/facts'
)
]
]
tables
=
[
tables
=
[
Table
(
Table
(
name
=
xml_column
.
attrib
[
'name'
],
name
=
xml_column
.
attrib
[
'name'
],
columns
=
xml_column
.
find
(
'columns'
).
text
.
split
(
','
),
columns
=
xml_column
.
find
(
'columns'
).
text
.
split
(
','
),
new_names
=
{
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
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
[
return
[
...
@@ -359,15 +356,12 @@ class ConfigParser:
...
@@ -359,15 +356,12 @@ class ConfigParser:
name
=
xml_cube
.
find
(
'name'
).
text
,
name
=
xml_cube
.
find
(
'name'
).
text
,
source
=
xml_cube
.
find
(
'source'
).
text
,
source
=
xml_cube
.
find
(
'source'
).
text
,
facts
=
facts
,
facts
=
facts
,
tables
=
tables
tables
=
tables
)
for
xml_cube
in
tree
.
xpath
(
'/cubes/cube'
)
)
for
xml_cube
in
tree
.
xpath
(
'/cubes/cube'
)
]
]
# except:
# except:
# raise ('Bad configuration in the configuration file')
# 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.
Construct cube (with it dimensions) and facts from the config file.
:param client_type: excel | web
:param client_type: excel | web
...
...
olapy/core/mdx/tools/connection.py
View file @
151cddf3
...
@@ -5,16 +5,18 @@ USERNAME = 'postgres'
...
@@ -5,16 +5,18 @@ USERNAME = 'postgres'
PASSWORD
=
'root'
PASSWORD
=
'root'
HOST
=
'localhost'
HOST
=
'localhost'
class
MyDB
(
object
):
class
MyDB
(
object
):
"""Connect to sql database (postgres only right now)."""
"""Connect to sql database (postgres only right now)."""
def
__init__
(
self
,
def
__init__
(
self
,
username
=
USERNAME
,
username
=
USERNAME
,
password
=
PASSWORD
,
password
=
PASSWORD
,
db
=
None
,
db
=
None
,
host
=
HOST
):
host
=
HOST
):
if
db
is
None
:
if
db
is
None
:
self
.
connection
=
pg
.
connect
(
self
.
connection
=
pg
.
connect
(
"user={0} password={1} host='{2}'"
.
"user={0} password={1} host='{2}'"
.
format
(
username
,
password
,
host
))
format
(
username
,
password
,
host
))
else
:
else
:
try
:
try
:
self
.
connection
=
pg
.
connect
(
self
.
connection
=
pg
.
connect
(
...
...
olapy/core/mdx/tools/models.py
View file @
151cddf3
...
@@ -37,6 +37,7 @@ class Dimension:
...
@@ -37,6 +37,7 @@ class Dimension:
def
__str__
(
self
):
def
__str__
(
self
):
return
str
(
self
.
__dict__
)
return
str
(
self
.
__dict__
)
class
Cube
:
class
Cube
:
"""Cube class used to encapsulate config file attributes."""
"""Cube class used to encapsulate config file attributes."""
...
@@ -52,6 +53,7 @@ class Cube:
...
@@ -52,6 +53,7 @@ class Cube:
def
__str__
(
self
):
def
__str__
(
self
):
return
str
(
self
.
__dict__
)
return
str
(
self
.
__dict__
)
class
Table
:
class
Table
:
"""Column class used to encapsulate config file attributes for web client."""
"""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