-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestENV.py
More file actions
66 lines (52 loc) · 1.93 KB
/
TestENV.py
File metadata and controls
66 lines (52 loc) · 1.93 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
66
#!/usr/bin/python
# Allow Display of elements in HTML
import pymysql.cursors
import CoreFiles
print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<head>')
print('<title>Team 2062s Scouting Match Table Report</title>')
print('</head>')
connection = pymysql.connect(host=CoreFiles.DatabaseCredentials.DB_HOST,
user=CoreFiles.DatabaseCredentials.DB_USER,
password=CoreFiles.DatabaseCredentials.DB_PASS,
database=CoreFiles.DatabaseCredentials.DB_NAME,
charset='utf8mb4',
cursorclass=CoreFiles.pymysql.cursors.DictCursor)
"""try:
with connection.cursor() as cursor:
test = "INSERT INTO `2062` (`hasAuto`, `defenceType`, `hasDefender`, `numhighgoals`, `numlowgoals`, `comments`) VALUES (%s, %s, %s, %s, %s, %s)"
cursor.execute(test, ('nope', 'yes', 'nope', 32, 1, 'gobolyguk'))
connection.commit()
finally:
connection.close()
"""
team_number = 1
dictionary = {}
try:
with connection.cursor() as cursor:
sql = ("SELECT * FROM `1` ORDER BY `match_id`")
cursor.execute(sql)
#all_data = cursor.fetchall()
id = cursor.fetchone()
count = 0
while id is not None:
keys = id.keys()
values = id.values()
if count == 0:
for (key, value) in zip(keys, values):
dictionary[key] = (value,)
count = 1
else:
for (key, value) in zip(keys, values):
dictionary[key] += (value,)
id = cursor.fetchone()
finally:
connection.close()
for item in dictionary:
print("<p>" + item + "</p>")
for thing in dictionary[item]:
print("<p>" + str(thing) + "</p>")
print('<body>')
print('</body>')
print('</html>')