-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataTableReader.py
66 lines (53 loc) · 1.93 KB
/
DataTableReader.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
import SQLcommands
from DataTable import DataTable
class DataTableReader(DataTable):
def __init__(self, dbname, sex):
DataTable.__init__(self, dbname)
self.sex = sex
def avg_participants(self, region, year):
self.cur.execute(SQLcommands.Commands.get_avg_participants(region, year, self.sex))
dane = self.cur.fetchall()
print("1)")
for dana in dane:
print(dana[0], dana[1])
print()
return dane
def percentage_passed(self, region):
self.cur.execute(SQLcommands.Commands.get_percentage_passed(region, self.sex))
passed = self.cur.fetchall()
print("2)")
for p in passed:
print(p[0], str(int(p[1])) + "%", )
print()
def best_region(self, year):
self.cur.execute(SQLcommands.Commands.get_best_region(year, self.sex))
best = self.cur.fetchall()
print("3)")
for b in best:
print(b[0], str(int(b[1])) + "%", )
print()
def regression_checker(self):
self.cur.execute(SQLcommands.Commands.get_regression(self.sex))
result = self.cur.fetchall()
previous_result = result[0][2]
previous_region = result[0][1]
print("4)")
for reg in result:
if previous_region != reg[1]:
previous_result = reg[2]
previous_region = reg[1]
if reg[2] < previous_result:
print(reg[1] + ":", reg[0] + " ->", str(int(reg[0]) - 1))
previous_result = reg[2]
print()
def comparison(self, region1, region2):
self.cur.execute(SQLcommands.Commands.get_comparison(region1, region2, self.sex))
results = self.cur.fetchall()
print("5)")
for result in results:
if result[2] > result[4]:
bigger = result[1]
else:
bigger = result[3]
print(result[0], bigger)
print()