-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbupdater.py
37 lines (29 loc) · 892 Bytes
/
dbupdater.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
import os
import sys
import time
import mysql.connector
def dbupdate():
mydb = mysql.connector.connect(host="localhost",user="root",passwd="root",database="facedb")
mycursor = mydb.cursor()
dir = os.path.join(os.getcwd(),'detected')
#print(dir)
list1 = os.listdir(dir)
#print(list1)
for x in list1 :
#print(x," Detected!!")
sql ="UPDATE userdata SET found = 1 WHERE name =%s "
val = (x,)
mycursor.execute(sql,val)
mydb.commit()
while True :
dbupdate()
dir = os.path.join(os.getcwd(),'detected')
list = os.listdir(dir)
prevlen = len(list)
time.sleep(5)
dir = os.path.join(os.getcwd(),'detected')
list = os.listdir(dir)
curlen = len(list)
if curlen != prevlen :
print("Entry Add or Delete Detected")
dbupdate()