-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqll.py
35 lines (33 loc) · 973 Bytes
/
sqll.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
import MySQLdb
def adduser(xuehao,mima):
db = MySQLdb.connect("127.0.0.1", port=3306,user= "XXXX",passwd= "XXXXX",db="XXXX", charset='utf8' )
cursor=db.cursor()
try:
cursor.execute("INSERT INTO `xsb`(`xuehao`, `mima`) VALUES ("+"\""+str(xuehao)+"\",\""+str(mima)+"\")")
db.commit()
db.close()
return 0
except:
db.close()
return 1
def banuser(xuehao):
db = MySQLdb.connect("127.0.0.1", port=3306,user= "XXXX",passwd= "XXXXX",db="XXXX", charset='utf8' )
cursor=db.cursor()
cursor.execute("UPDATE `xsb` SET `isdel`=1 WHERE xuehao="+str(xuehao))
db.commit()
db.close()
selectall()
return 0
def selectall():
db = MySQLdb.connect("127.0.0.1", port=3306,user= "XXXX",passwd= "XXXXX",db="XXXX", charset='utf8' )
cursor=db.cursor()
cursor.execute("select * from xsb")
db.commit()
b=cursor.fetchall()
db.close()
#for i in b:
# print(i[0],i[1],i[2])
return b
#adduser(12,2)
banuser(999)
selectall()