-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbig.py
30 lines (30 loc) · 986 Bytes
/
big.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
from matplotlib import pyplot as plt
import numpy as np
from collections import Counter as Cot
import pymysql
conn = pymysql.connect(host=input("host>"), user=input("user>"), passwd=input("passwd>"), db=input("[testdb] db>"))
cursor = conn.cursor()
while True:
inp = input(">")
while inp == "inp":
u = input("h>")
j = []
if len(u) == 5:
for i in u:
j.append(int(i))
print(j)
cursor.execute("INSERT INTO COMP (a,b,c,d,e) values(%s,%s,%s,%s,%s)", tuple(j))
conn.commit()
if inp == "show":
j = []
cursor.execute("select " + input(">") + " from comp;")
for i in cursor:
j.append(i[0])
res = Cot(j)
for i in list("12345"):
if not res[int(i)]:
res[int(i)] = 0
x = np.array(["1", "2", "3", "4", "5"])
y = np.array([res[1], res[2], res[3], res[4], res[5]])
plt.bar(x, y)
plt.show()