-
Notifications
You must be signed in to change notification settings - Fork 0
/
koneksi.py
47 lines (34 loc) · 1.1 KB
/
koneksi.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
import mysql.connector
conn = mysql.connector.connect(
user='root',
password='',
host='localhost',
database='db_handwashing'
)
cursor = conn.cursor()
def savelog():
memulai = "INSERT INTO t_log(log)VALUES ('Menghubungkan server')"
cursor.execute(memulai)
conn.commit()
def saveHistory(poseCount, totalFrames):
summary = "INSERT INTO t_summary(poseCount, totalFrames)VALUES ('"+str(
poseCount)+"','" + str(totalFrames)+"' )"
cursor.execute(summary)
conn.commit()
def getLastHistory():
sql = 'SELECT poseCount, totalFrames FROM `t_summary` ORDER BY id DESC LIMIT 1'
cursor.execute(sql)
result = cursor.fetchall()
if cursor.rowcount > 0:
for data in result:
pose = data[0]
total = data[1]
poseCount = pose
totalFrames = int(total)
kata = poseCount
remove_characters = ["[", "]"]
for item in remove_characters:
kata = kata.replace(item, "")
x = kata.split()
return x, totalFrames
# print(getLastHistory())