-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_file.py
60 lines (41 loc) · 1.3 KB
/
main_file.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import database
import overall_details
import sql_query_details
def compare():
base_op = open("base_output.txt", "r")
op = open("output.txt", "r")
log = open("log.txt", "w")
line1 = next(base_op)
line2 = next(op)
count = 1
while line1 and line2:
if line1 != line2:
log.write("Query %d\n" % count)
print("Query ", count)
count += 1
line1 = next(base_op)
line2 = next(op)
base_op.close()
op.close()
log.close()
op_file = open("output.txt", "w")
db = database.Database("localhost", "root", "Nprabhav@96", "emp")
db.connect()
overall_details = overall_details.OverallDetails(db)
overall_details.collect_details()
count = 1
with open('ip1.txt') as fp:
for line in fp:
natural_lang_query = line.strip('\n')
print("%d %s" % (count, natural_lang_query))
sql_query_details_obj = sql_query_details.SQLQueryDetails(db, overall_details)
clauses = sql_query_details_obj.collect_query_details(natural_lang_query)
[query, type_query] = clauses.create_query()
# use the type variable wherever you want
print("\n-----------")
print("Final query: ", query)
print("-----------\n")
op_file.write(query + "\n")
count += 1
op_file.close()
# compare()