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
060e3281
Commit
060e3281
authored
Jun 06, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix config path (with olapy-web flask instance_path)
parent
93df06cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
+15
-7
olapy/core/mdx/executor/execute.py
olapy/core/mdx/executor/execute.py
+10
-3
olapy/core/mdx/executor/execute_config_file.py
olapy/core/mdx/executor/execute_config_file.py
+2
-1
olapy/core/mdx/executor/execute_db.py
olapy/core/mdx/executor/execute_db.py
+1
-1
olapy/core/mdx/tools/connection.py
olapy/core/mdx/tools/connection.py
+2
-2
No files found.
olapy/core/mdx/executor/execute.py
View file @
060e3281
...
...
@@ -33,6 +33,9 @@ class MdxEngine:
:param sep: separator in the csv files
"""
# DATA_FOLDER useful for olapy web (falsk instance_path)
# get olapy-data path with instance_path instead of 'expanduser'
DATA_FOLDER
=
None
CUBE_FOLDER
=
"cubes"
# (before instantiate MdxEngine I need to access cubes information)
csv_files_cubes
=
[]
...
...
@@ -75,7 +78,12 @@ class MdxEngine:
""":return: list cubes name that exists in cubes folder (under ~/olapy-data/cubes) and postgres database (if connected)."""
# get csv files folders (cubes)
# toxworkdir does not expanduser properly under tox
if
RUNNING_TOX
:
# surrended with try, except and PASS so we continue getting cubes from different
# sources (db, csv...) without interruption
if
cls
.
DATA_FOLDER
is
not
None
:
home_directory
=
cls
.
DATA_FOLDER
elif
RUNNING_TOX
:
home_directory
=
os
.
environ
.
get
(
'HOME_DIR'
)
else
:
home_directory
=
expanduser
(
"~"
)
...
...
@@ -94,7 +102,7 @@ class MdxEngine:
# get postgres databases
try
:
db
=
MyDB
()
db
=
MyDB
(
db_config_file_path
=
cls
.
DATA_FOLDER
)
connection
=
db
.
engine
# TODO this work only with postgres
result
=
connection
.
execute
(
'SELECT datname FROM pg_database WHERE datistemplate = false;'
)
...
...
@@ -174,7 +182,6 @@ class MdxEngine:
:return: star schema DataFrame
"""
fusion
=
None
config_file_parser
=
ConfigParser
(
self
.
cube_path
)
if
config_file_parser
.
config_file_exist
(
self
.
client
...
...
olapy/core/mdx/executor/execute_config_file.py
View file @
060e3281
...
...
@@ -2,6 +2,7 @@ from __future__ import absolute_import, division, print_function
from
..tools.connection
import
MyDB
import
pandas.io.sql
as
psql
import
os
def
_load_table_config_file
(
executer_instance
,
cube_obj
):
...
...
@@ -83,7 +84,7 @@ def _construct_web_star_schema_config_file(executer_instance, cubes_obj):
all_columns
=
[]
executer_instance
.
facts
=
cubes_obj
.
facts
[
0
].
table_name
db
=
MyDB
(
db
=
executer_instance
.
cube
)
db
=
MyDB
(
db
=
executer_instance
.
cube
,
db_config_file_path
=
os
.
path
.
join
(
executer_instance
.
cube_path
,
".."
)
)
# load facts table
if
cubes_obj
.
facts
[
0
].
columns
:
...
...
olapy/core/mdx/executor/execute_db.py
View file @
060e3281
...
...
@@ -13,7 +13,7 @@ def _load_tables_db(executer_instance):
:return: tables dict with table name as key and dataframe as value
"""
tables
=
{}
db
=
MyDB
(
db
=
executer_instance
.
cube
)
db
=
MyDB
(
db
_config_file_path
=
executer_instance
.
DATA_FOLDER
,
db
=
executer_instance
.
cube
)
inspector
=
inspect
(
db
.
engine
)
for
table_name
in
inspector
.
get_table_names
():
...
...
olapy/core/mdx/tools/connection.py
View file @
060e3281
...
...
@@ -17,10 +17,10 @@ class MyDB(object):
# raise Exception('Missing database config file')
def
__init__
(
self
,
db
=
None
):
def
__init__
(
self
,
db
_config_file_path
=
None
,
db
=
None
):
# TODO temporary
db_config
=
DbConfigParser
()
db_config
=
DbConfigParser
(
config_path
=
db_config_file_path
)
db_credentials
=
db_config
.
get_db_credentials
()[
0
]
username
=
db_credentials
[
'user_name'
]
password
=
db_credentials
[
'password'
]
...
...
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