-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdb.py
More file actions
executable file
·32 lines (31 loc) · 976 Bytes
/
pdb.py
File metadata and controls
executable file
·32 lines (31 loc) · 976 Bytes
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
from Parser import Parser
from lifted_inference import *
from query2sql import *
import time
def main():
parser = Parser()
parser.connect()
parser.parse()
startTime = time.time()
lifted_query = perform_inference_dnf(parser.queries[0])
if lifted_query:
print("\nLifted Query:")
print(lifted_query.tostring())
v = sqlVistor()
sql_query = lifted_query.accept(v)
print("\nSQL Query:")
print(sql_query)
parser.cur.execute(sql_query + ";")
print("Result probability:")
for record in parser.cur:
if record[0]:
print(record[0])
else:
print("Calculation has failed. Probably due to nonexistent table.")
else:
print("\n Query is unliftable.")
print("\n Execution Time of lifting and querying (if query was liftable): " +
str(time.time() - startTime))
parser.close()
if __name__ == '__main__':
main()