/
BIBIUserODB.py
49 lines (38 loc) · 1.05 KB
/
BIBIUserODB.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
#!/usr/bin/python
#coding:utf-8
import conn
import re
class BIBIUserODB:
def __init__(self, username):
self.userName = username
def registerAccount(self, passwd, tishi = "忘记密码"):
checkSql = "select * from bibi_admin \
where name = '%s'" % (self.userName)
conn.cursor.execute(checkSql)
checkIsOk = conn.cursor.fetchone()
print checkIsOk
if (checkIsOk == None):
regSql = "insert into bibi_admin (name, pwd, tishi) \
values('%s', '%s', '%s')" % (self.userName, passwd, tishi)
#print regSql
try:
conn.cursor.execute(regSql)
except:
print "Error:regAcconut"
return True
else:
return False
def loginAccount(self, passwd):
loginSql = """select * from bibi_admin
where name = '%s'
""" % (self.userName)
conn.cursor.execute(loginSql)
infoList = conn.cursor.fetchone()
if (infoList == None):
return "Error:Name is wrong"
elif(infoList[2] == passwd):
return "GoodJob"
else:
return "Error:passwd is wrong"
def commit(self):
conn.commit()