-
Notifications
You must be signed in to change notification settings - Fork 0
/
libData.py
89 lines (76 loc) · 2.29 KB
/
libData.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import MySQLdb
from datetime import date
from datetime import datetime
import tkinter as tk
global db
def getData(getOut):
today = date.today()
now = datetime.now()
if getOut == "tangal":
return today.strftime("%Y/%m/%d")
if getOut == "waktu":
#return now.strftime("%H:%M:%S")
return now.strftime("%H:%M")
def keDb():
global db
db = MySQLdb.connect(host="localhost",user="root",passwd="",db="absen")
'''
cursor = db.cursor()
cursor.execute("SELECT * FROM `data-angota`")
numrows = cursor.rowcount
for x in range(0, numrows):
row = cursor.fetchone()
print (row[0],row[1],row[2],row[3])
db.close()
'''
def tutupDb():
global db
db.close()
def qSql():
global db
cursor = db.cursor()
cursor.execute("SELECT * FROM `log-absen`")
numrows = cursor.rowcount
for x in range(0, numrows):
row = cursor.fetchone()
print (row[0],row[1],row[2],row[3],row[4],row[5])
class simpanData:
matkul =""
nama =""
noId = ""
def qPSql(dataIn):
global db
cursor = db.cursor()
cursor.execute("SELECT dataIn FROM `log-absen` WHERE id = "+simpanData.noId+"")
numrows = cursor.rowcount
row = cursor.fetchone()
return row[0]
def getNama():
global db
cursor = db.cursor()
cursor.execute("SELECT nama FROM `data-angota` WHERE id = "+simpanData.noId+"")
numrows = cursor.rowcount
row = cursor.fetchone()
return row[0]
def iSql():
simpanData.nama=simpanData.getNama()
global db
cursor = db.cursor()
cursor.execute("INSERT into `log-absen` (`status`,`id`,`nama`,`hari`,`jam`,`matkul`) VALUES (%s,%s,%s,%s,%s,%s)",("0",""+simpanData.noId+"",""+simpanData.nama+"",getData("tangal"),getData("waktu"),""+simpanData.matkul+""))
db.commit()
class dataDataBuff:
mataKuliah =""
master = 0
def inputAction():
global buffString
dataDataBuff.mataKuliah = buffString.get()
dataDataBuff.master.destroy()
dataDataBuff.master.quit()
def inputMataKuliah():
dataDataBuff.master = tk.Tk()
global buffString
buffString = tk.StringVar(dataDataBuff.master)
tk.Label(dataDataBuff.master, text="INPUT MATKUL").grid(row=0)
tk.Entry(dataDataBuff.master,textvariable = buffString).grid(row=0, column=1)
tk.Button(dataDataBuff.master,text='OK',command=inputAction).grid(row=0, column=2)
dataDataBuff.master.mainloop()