def searchbyid(id):
		db=DBconnection.connect()
		cursor=db.cursor()
		q='select * from usermaster where userid=%s'
		data=[]
		data.append(id)
		cursor.execute(q,data)
		cur=cursor.fetchall()
		if (cursor.rowcount==1):
			for row in cur:
				usr=user()
				usr.setUserid(int(row[0]))
				usr.setUsername(row[1])
				usr.setPassword(row[2])
				usr.setUsertype(row[3])
				usr.setUserstatus(bool(row[4]))
				usr.setName(row[5])
				usr.setEmail(row[6])
				usr.setContact(row[7])
				usr.setAddress(row[8])
				usr.setGender(bool(row[9]))
			cursor.close()
			db.close()
			return usr
		else:
			cursor.close()
			db.close()
			return None
Ejemplo n.º 2
0
	def logout(uid):
		cnx=DBconnection.connect()
		cur=cnx.cursor()
		q="update usermaster set online='inactive' where userid=%s"
		cur.execute(q,(uid,))
		cnx.commit()
		cur.close()
		cnx.close()
Ejemplo n.º 3
0
	def login(usrname,passwd):
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select * from usermaster'
		cursor.execute(query)
		for row in cursor:
			if row[1]==usrname and row[2]==passwd:
				return row[0],row[1]
		return -1,'0'
	def SetPortno(no):
		db=DBconnection.connect()
		cursor=db.cursor()
		val=[]
		query='update portno set portno=%s'
		val.append(no)
		cursor.execute(query,val)
		cursor.close()
		db.commit()
	def InActive(user):
		db=DBconnection.connect()
		cursor=db.cursor()
		values=[]
		query='update usermaster set online=%s where username=%s'
		values.append('inactive')
		values.append(user)
		cursor.execute(query,values)
		cursor.close()
		db.commit()
	def SetStatus(no):
		db=DBconnection.connect()
		cursor=db.cursor()
		val=[]
		query='update stopserver set status=%s'
		val.append(no)
		cursor.execute(query,val)
		cursor.close()
		db.commit()
					
	def GetPortno():
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select * from portno'
		cursor.execute(query)
		for i in cursor:
			prt=int(i[0])
			break
		cursor.close()
		db.close()
		return prt
	def online_user():
		list=[]
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select username from usermaster where online=%s'
		list.append('active')
		cursor.execute(query,list)
		cur=cursor.fetchall()
		cursor.close()
		db.close()
		return cur			
	def GetStatus():
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select * from stopserver'
		cursor.execute(query)
		for i in cursor:
			prt=int(i[0])
			break
		cursor.close()
		db.close()
		return prt
Ejemplo n.º 10
0
	def changePassword(usr,old,new):
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select password from usermaster where username=%s'
		cursor.execute(query,(usr,))
		cur=cursor.fetchall()
		for row in cur:
			if row[0]==old:
				qry='update usermaster set password=%s where username=%s'
				cursor.execute(qry,(new,usr))
				db.commit()
				cursor.close()
				return True
		return False
	def updateprofile(user):		
		db=DBconnection.connect()
		cursor=db.cursor()
		query='update usermaster set name=%s,email=%s,contact=%s,address=%s,gender=%s where userid=%s'
		values=[]
		values.append(user.getName())
		values.append(user.getEmail())
		values.append(user.getContact())
		values.append(user.getAddress())
		values.append(user.getGender())
		values.append(user.getUserid())
		cursor.execute(query,values)
		if(cursor.rowcount==1):
			db.commit()
			cursor.close()
			return True
		else:
			db.commit()
			cursor.close()
			return False
	def view():
		list=[]
		db=DBconnection.connect()
		cursor=db.cursor()
		query='select * from usermaster'
		cursor.execute(query)
		cur=cursor.fetchall()
		for row in cur:
			usr=user()
			usr.setUserid(int(row[0]))
			usr.setUsername(row[1])
			usr.setPassword(row[2])
			usr.setUsertype(row[3])
			usr.setUserstatus(bool(row[4]))
			usr.setName(row[5])
			usr.setEmail(row[6])
			usr.setContact(row[7])
			usr.setAddress(row[8])
			usr.setGender(bool(row[9]))
			list.append(usr)
		cursor.close()
		db.close()
		return list
	def add(user):
		try:
			db=DBconnection.connect()
			cursor=db.cursor()
			query='insert into usermaster(username,password,usertype,userstatus,name,email,contact,address,gender) values(%s,%s,%s,%s,%s,%s,%s,%s,%s)'
			values=[]
			values.append(user.getUsername())
			values.append(user.getPassword())
			values.append(user.getUsertype())
			values.append(user.getUserstatus())
			values.append(user.getName())
			values.append(user.getEmail())
			values.append(user.getContact())
			values.append(user.getAddress())
			values.append(user.getGender())
			cursor.execute(query,values)
			if(cursor.rowcount==1):
				db.commit()
				cursor.close()
				return True
		except:
			cursor.close()
			db.commit()
			return False