-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.py
More file actions
65 lines (55 loc) · 1.52 KB
/
example.py
File metadata and controls
65 lines (55 loc) · 1.52 KB
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
58
59
60
61
62
63
64
65
import logging
from polygon.testers.mysql_tester import MySQLTester
from polygon.testers.mysql_tester import DB_CONFIG
from polygon.environment import Environment
from polygon.logger import logger
def main():
logger.setLevel(logging.DEBUG)
schema = [
{
"TableName": "Employees",
"PKeys": [
{
"Name": "emp_id",
"Type": "int"
}
],
"FKeys": [],
"Others": [
{
"Name": "name",
"Type": "varchar"
},
{
"Name": "age",
"Type": "int"
}
]
}
]
constraints = [{'distinct': ['Employees.emp_id']}]
env = Environment(schema, constraints, bound=2, time_budget=60)
queries = [
"""
SELECT emp_id FROM Employees WHERE age > 30
""",
"""
SELECT emp_id FROM Employees WHERE age >= 30
"""
]
eq, cex, checking_time, total_time, ret = env.check(*queries)
print(ret)
if eq is None:
print('ERR')
else:
if not eq:
print('NEQ', total_time)
logger.info(cex)
with MySQLTester(DB_CONFIG, schema) as tester:
tester.create_all_databases([cex], constraints)
rejected = tester.test_pair(*queries)
print(rejected)
else:
print('EQ')
if __name__ == '__main__':
main()