-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.py
40 lines (31 loc) · 1.02 KB
/
execute.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from class_table import *
from helper import *
from execute_where import *
from execute_select import *
def execute(parsed_list):
select_query = parsed_list[0]
from_query = parsed_list[1]
where_query = parsed_list[2]
table_list = getDB()
result = ValidateTablename(from_query, table_list)
if result != True:
return result
X, Y = GetTablesRows(from_query, table_list)
if Y == []:
joinTable = X
else:
joinTable = Join(X, Y)
require_tables = []
for tname in from_query:
for t in table_list:
if tname == t.name:
require_tables.append(t)
if where_query != []:
result, joinTable = execute_where(joinTable, where_query, from_query, require_tables)
if result != True:
return result
result, finalTable = execute_select(joinTable, select_query, from_query, require_tables)
if result != True:
return result
printTable(finalTable, select_query, require_tables)
return True