-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.py
66 lines (51 loc) · 2.11 KB
/
tester.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
58
59
60
61
62
63
64
65
66
#!/usr/bin/python2.7
#
#Tester for students
# Do not hard code values in your program for ratings.
# table name and input file name.
# Do not close con objects in your program.
# Invalid ranges will not be tested.
# Order of output does not matter, only correctness will be checked.
# Use discussion board extensively to clear doubts.
# Sample output does not correspond to data in test_data.txt.
#
import traceback
DATABASE_NAME = 'dds_assignment'
import Assignment1 as Assignment1
import interface as Assignment2
if __name__ == '__main__':
try:
#Creating Database ddsassignment2
print "Creating Database named as " + DATABASE_NAME
Assignment1.createDB(DATABASE_NAME);
# Getting connection to the database
print "Getting connection from the "+ DATABASE_NAME + " database"
con = Assignment1.getOpenConnection(dbname=DATABASE_NAME);
# Clear the database existing tables
print "Delete tables"
Assignment1.deleteTables('all', con);
# Loading Ratings table
print "Creating and Loading the ratings table"
Assignment1.loadRatings('ratings', 'test_data.txt', con);
# Doing Range Partition
print "Doing the Range Partitions"
Assignment1.rangePartition('ratings', 5, con);
# Doing Round Robin Partition
print "Doing the Round Robin Partitions"
Assignment1.roundRobinPartition('ratings', 5, con);
# Deleting Ratings Table because Point Query and Range Query should not use ratings table instead they should use partitions.
Assignment1.deleteTables('ratings', con);
# Calling RangeQuery
print "Performing Range Query"
Assignment2.RangeQuery('ratings',3.5,4.5, con);
#Assignment2.RangeQuery('ratings',1,4,con);
# Calling PointQuery
print "Performing Point Query"
Assignment2.PointQuery('ratings', 4.5, con);
#Assignment2.PointQuery('ratings',2,con);
# Deleting All Tables
# Assignment1.deleteTables('all', con);
if con:
con.close()
except Exception as detail:
traceback.print_exc()