Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Imène Lajili
clowdflows
Commits
b89e2c26
Commit
b89e2c26
authored
Feb 07, 2013
by
bogdan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of workflow.ijs.si:mothra into searchFunct
parents
7dd33198
db580e10
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
346 additions
and
320 deletions
+346
-320
workflows/mysql/context.py
workflows/mysql/context.py
+15
-5
workflows/mysql/db/package_data.json
workflows/mysql/db/package_data.json
+328
-310
workflows/mysql/interaction_views.py
workflows/mysql/interaction_views.py
+3
-3
workflows/mysql/templates/interactions/db_context.html
workflows/mysql/templates/interactions/db_context.html
+0
-2
No files found.
workflows/mysql/context.py
View file @
b89e2c26
...
...
@@ -24,7 +24,7 @@ class DBConnection:
return
sql
.
connect
(
user
=
self
.
user
,
password
=
self
.
password
,
host
=
self
.
host
,
database
=
self
.
database
)
class
DBContext
:
def
__init__
(
self
,
connection
):
def
__init__
(
self
,
connection
,
find_connections
=
False
):
'''
Initializes the fields:
tables: list of selected tables
...
...
@@ -36,7 +36,6 @@ class DBContext:
pkeys: private key for a given table
target_table: selected table for learning
target_att: selected column for learning
target_att_val: selected target att value
'''
self
.
connection
=
connection
con
=
connection
.
connect
()
...
...
@@ -54,18 +53,27 @@ class DBContext:
for
col
in
cols
:
cursor
.
execute
(
"SELECT DISTINCT `%s` FROM `%s` LIMIT 51"
%
(
col
,
table
))
self
.
col_vals
[
table
][
col
]
=
[
val
for
(
val
,)
in
cursor
]
print
self
.
col_vals
self
.
connected
=
{}
cursor
.
execute
(
"SELECT table_name, column_name, referenced_table_name, referenced_column_name
\
FROM information_schema.KEY_COLUMN_USAGE
\
WHERE referenced_table_name IS NOT NULL AND table_schema='%s'"
%
connection
.
database
)
self
.
fkeys
=
defaultdict
(
set
)
self
.
pkeys
=
{}
if
find_connections
:
for
table
in
self
.
tables
:
for
col
in
self
.
cols
[
table
]:
if
col
.
endswith
(
'_id'
):
ref_table
=
(
col
[:
-
4
]
+
'ies'
)
if
col
[
-
4
]
==
'y'
else
(
col
[:
-
3
]
+
's'
)
self
.
connected
[(
table
,
ref_table
)]
=
(
col
,
'id'
)
self
.
connected
[(
ref_table
,
table
)]
=
(
'id'
,
col
)
self
.
fkeys
[
table
].
add
(
col
)
if
col
==
'id'
:
self
.
pkeys
[
table
]
=
col
for
(
table
,
col
,
ref_table
,
ref_col
)
in
cursor
:
self
.
connected
[(
table
,
ref_table
)]
=
(
col
,
ref_col
)
self
.
connected
[(
ref_table
,
table
)]
=
(
ref_col
,
col
)
self
.
fkeys
[
table
].
add
(
col
)
self
.
pkeys
=
{}
cursor
.
execute
(
"SELECT table_name, column_name
\
FROM information_schema.KEY_COLUMN_USAGE
\
...
...
@@ -126,5 +134,7 @@ class DBContext:
return
types
def
__repr__
(
self
):
return
str
((
self
.
target_table
,
self
.
target_att
,
self
.
tables
,
self
.
cols
,
self
.
connected
))
#import pprint
#return pprint.pformat((self.target_table, self.target_att, self.tables, self.cols, self.connected, self.pkeys, self.fkeys))
return
'fkeys : '
+
str
(
self
.
fkeys
)
workflows/mysql/db/package_data.json
View file @
b89e2c26
[
{
"pk"
:
39
,
"pk"
:
20
,
"model"
:
"workflows.category"
,
"fields"
:
{
"uid"
:
"b66b71b1-99d6-4efc-b264-a914a3e42911"
,
...
...
@@ -12,10 +12,10 @@
}
},
{
"pk"
:
1
90
,
"pk"
:
1
04
,
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
39
,
"category"
:
20
,
"treeview_image"
:
""
,
"name"
:
"Database Context"
,
"is_streaming"
:
false
,
...
...
@@ -37,10 +37,10 @@
}
},
{
"pk"
:
44
3
,
"pk"
:
21
3
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
90
,
"widget"
:
1
04
,
"name"
:
"connection"
,
"short_name"
:
"con"
,
"uid"
:
"6c23b4a2-a18e-498e-a22c-4de86932da3e"
,
...
...
@@ -55,10 +55,28 @@
}
},
{
"pk"
:
216
,
"pk"
:
236
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
104
,
"name"
:
"Table connection from names"
,
"short_name"
:
"tbc"
,
"uid"
:
"be3718eb-062e-48f2-af2a-8c31e66524fe"
,
"default"
:
"false"
,
"required"
:
true
,
"multi"
:
false
,
"parameter_type"
:
"checkbox"
,
"variable"
:
"find_connections"
,
"parameter"
:
true
,
"order"
:
1
,
"description"
:
"Tries to detect connections between tables solely by looking at the attribute names."
}
},
{
"pk"
:
117
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
90
,
"widget"
:
1
04
,
"name"
:
"context"
,
"short_name"
:
"cxt"
,
"variable"
:
"context"
,
...
...
@@ -68,10 +86,10 @@
}
},
{
"pk"
:
1
91
,
"pk"
:
1
05
,
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
39
,
"category"
:
20
,
"treeview_image"
:
""
,
"name"
:
"Database To Aleph"
,
"is_streaming"
:
false
,
...
...
@@ -93,10 +111,10 @@
}
},
{
"pk"
:
451
,
"pk"
:
235
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
91
,
"widget"
:
1
05
,
"name"
:
"Target attribute value"
,
"short_name"
:
"tgt"
,
"uid"
:
"5b7354f1-35d8-41c8-a0ae-c3848855f29d"
,
...
...
@@ -111,10 +129,10 @@
}
},
{
"pk"
:
44
4
,
"pk"
:
21
4
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
91
,
"widget"
:
1
05
,
"name"
:
"context"
,
"short_name"
:
"cxt"
,
"uid"
:
"474e9673-9c55-48c5-bae8-a7b986aa0287"
,
...
...
@@ -129,10 +147,10 @@
}
},
{
"pk"
:
217
,
"pk"
:
118
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
91
,
"widget"
:
1
05
,
"name"
:
"pos_examples"
,
"short_name"
:
"pex"
,
"variable"
:
"pos_examples"
,
...
...
@@ -142,10 +160,10 @@
}
},
{
"pk"
:
218
,
"pk"
:
119
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
91
,
"widget"
:
1
05
,
"name"
:
"neg_examples"
,
"short_name"
:
"nex"
,
"variable"
:
"neg_examples"
,
...
...
@@ -155,10 +173,10 @@
}
},
{
"pk"
:
219
,
"pk"
:
120
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
91
,
"widget"
:
1
05
,
"name"
:
"bk"
,
"short_name"
:
"bk"
,
"variable"
:
"bk"
,
...
...
@@ -168,10 +186,10 @@
}
},
{
"pk"
:
1
92
,
"pk"
:
1
06
,
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
39
,
"category"
:
20
,
"treeview_image"
:
""
,
"name"
:
"Database To Orange Table"
,
"is_streaming"
:
false
,
...
...
@@ -193,10 +211,10 @@
}
},
{
"pk"
:
44
5
,
"pk"
:
21
5
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
92
,
"widget"
:
1
06
,
"name"
:
"context"
,
"short_name"
:
"cxt"
,
"uid"
:
"1f9b5ccf-65c3-4ccc-818e-afb3a6ffee20"
,
...
...
@@ -211,10 +229,10 @@
}
},
{
"pk"
:
220
,
"pk"
:
121
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
92
,
"widget"
:
1
06
,
"name"
:
"Data table"
,
"short_name"
:
"odt"
,
"variable"
:
"dataset"
,
...
...
@@ -224,10 +242,10 @@
}
},
{
"pk"
:
1
93
,
"pk"
:
1
07
,
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
39
,
"category"
:
20
,
"treeview_image"
:
""
,
"name"
:
"Database To RSD"
,
"is_streaming"
:
false
,
...
...
@@ -249,10 +267,10 @@
}
},
{
"pk"
:
44
6
,
"pk"
:
21
6
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
93
,
"widget"
:
1
07
,
"name"
:
"context"
,
"short_name"
:
"cxt"
,
"uid"
:
"4f1397a8-4e72-4b34-b31d-d09bf9a7e7d9"
,
...
...
@@ -267,10 +285,10 @@
}
},
{
"pk"
:
22
1
,
"pk"
:
1
22
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
93
,
"widget"
:
1
07
,
"name"
:
"examples"
,
"short_name"
:
"exm"
,
"variable"
:
"examples"
,
...
...
@@ -280,10 +298,10 @@
}
},
{
"pk"
:
222
,
"pk"
:
123
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
93
,
"widget"
:
1
07
,
"name"
:
"bk"
,
"short_name"
:
"bk"
,
"variable"
:
"bk"
,
...
...
@@ -293,10 +311,10 @@
}
},
{
"pk"
:
1
94
,
"pk"
:
1
08
,
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
39
,
"category"
:
20
,
"treeview_image"
:
""
,
"name"
:
"MySQL Connect"
,
"is_streaming"
:
false
,
...
...
@@ -318,10 +336,10 @@
}
},
{
"pk"
:
44
7
,
"pk"
:
21
7
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
94
,
"widget"
:
1
08
,
"name"
:
"user"
,
"short_name"
:
"usr"
,
"uid"
:
"0f36f10b-066f-4ad3-9fa8-39205440076a"
,
...
...
@@ -336,10 +354,10 @@
}
},
{
"pk"
:
44
8
,
"pk"
:
21
8
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
94
,
"widget"
:
1
08
,
"name"
:
"password"
,
"short_name"
:
"pwd"
,
"uid"
:
"8ead911a-3d1b-4e50-b56a-64873b85d3cf"
,
...
...
@@ -354,10 +372,10 @@
}
},
{
"pk"
:
44
9
,
"pk"
:
21
9
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
94
,
"widget"
:
1
08
,
"name"
:
"host"
,
"short_name"
:
"hst"
,
"uid"
:
"9812cc11-b21e-4444-8dfe-bc0c68fe79e8"
,
...
...
@@ -372,10 +390,10 @@
}
},
{
"pk"
:
45
0
,
"pk"
:
22
0
,
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
1
94
,
"widget"
:
1
08
,
"name"
:
"database"
,
"short_name"
:
"db"
,
"uid"
:
"d132adce-c3ec-411a-8ee7-906be4a99f61"
,
...
...
@@ -390,10 +408,10 @@
}
},
{
"pk"
:
223
,
"pk"
:
124
,
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
1
94
,
"widget"
:
1
08
,
"name"
:
"connection"
,
"short_name"
:
"con"
,
"variable"
:
"connection"
,
...
...
workflows/mysql/interaction_views.py
View file @
b89e2c26
...
...
@@ -9,11 +9,11 @@ from context import DBContext
def
mysql_db_context
(
request
,
input_dict
,
output_dict
,
widget
):
con
=
input_dict
[
'connection'
]
initial_context
=
DBContext
(
con
)
find_con
=
input_dict
[
'find_connections'
]
==
'true'
initial_context
=
DBContext
(
con
,
find_connections
=
find_con
)
initial_target_cols
=
initial_context
.
cols
[
initial_context
.
target_table
]
initial_target_col_vals
=
initial_context
.
col_vals
[
initial_context
.
target_table
][
initial_target_cols
[
0
]]
cols_dump
=
json
.
dumps
(
initial_context
.
cols
)
col_vals_dump
=
json
.
dumps
(
initial_context
.
col_vals
)
return
render
(
request
,
'interactions/db_context.html'
,
{
'widget'
:
widget
,
'context'
:
initial_context
,
'target_cols'
:
initial_target_cols
,
'cols'
:
cols_dump
,
'col_vals'
:
col_vals_dump
,
'target_col_vals'
:
initial_target_col_vals
})
return
render
(
request
,
'interactions/db_context.html'
,
{
'widget'
:
widget
,
'context'
:
initial_context
,
'target_cols'
:
initial_target_cols
,
'cols'
:
cols_dump
,
'target_col_vals'
:
initial_target_col_vals
})
workflows/mysql/templates/interactions/db_context.html
View file @
b89e2c26
...
...
@@ -43,8 +43,6 @@
<script
type=
"text/javascript"
>
// Columns data.
var
cols
=
{{
cols
|
safe
}};
//var col_vals = {{col_vals|safe}};
console
.
log
(
col_vals
);
$
(
'
select[name="target_table{{widget.pk}}"]
'
).
change
(
function
()
{
var
selected_table
=
$
(
this
).
first
(
'
option:selected
'
).
val
();
var
available_cols
=
cols
[
selected_table
];
...
...
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