forked from jishnu7/SMS-Attendance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore.py
29 lines (20 loc) · 781 Bytes
/
restore.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
DBHOST = "localhost"
DBPASS = "root"
DBUSER = "root"
DB = "dbname"
import MySQLdb
db = MySQLdb.connect(host=DBHOST, user=DBUSER, passwd=DBPASS, db=DB)
f = open('attendance-log.txt', 'r')
for line in f.readlines():
a = line.split('DELETE')[1].split('\n')[0]
account = a.split(' ')[0]
password = account.split('.')[1]
mob = a.split(' ')[1]
cursor = db.cursor()
cursor.execute("SELECT username, passwd FROM users WHERE `username`='"+account+"' AND `mob`='"+mob+"'")
rows = int(cursor.rowcount)
if rows > 0:
continue
cursor.execute("INSERT INTO `users` (`username` ,`passwd` , `mob`) VALUES ( '"+account+"', '"+password+"', '"+mob+"')")
print account+'--'+password+'--'+mob
~