def updatelikecount(a, b, updateid1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("update updates set likes='" + str(a) + "',dislike='" + str(b) + " 'where updateid='" + str(updateid1) + "'") finally: cur.close() con.commit() con.close()
def chng_pwd(username, new_password): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("update user_details set password='******'where username='******'") finally: cur.close() con.commit() con.close()
def updatelike(username2, updateid2, status2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("update like_dislike set likestatus='" + status2 + "' where username='******' and updateid='" + str(updateid2) + "'") finally: cur.close() con.commit() con.close()
def insertlikestatus(username3, updateid3, status1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "insert into like_dislike(updateid,username,likestatus) values('" + str(updateid3) + "','" + username3 + "','" + status1 + "')") finally: cur.close() con.commit() con.close()
def checkusername(updateid4): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("select username from updates where updateid=:updateid", {"updateid": updateid4}) for i in cur: return i[0] finally: cur.close() con.close()
def add_friend(username1, username2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "insert into request_status(username,friend_username,status) values('" + username1 + "','" + username2 + "','Pending')") finally: cur.close() con.commit() con.close()
def insert_comment(username4, updateid4, comment1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "insert into comments(username,updateid,comments) values('" + username4 + "','" + str(updateid4) + "',:comment2)", {"comment2": comment1}) finally: cur.close() con.commit() con.close()
def get_username(username): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select username from user_details where username=:username", {"username": username}) for i in cur: return 1 return 0 finally: cur.close() con.close()
def getlikecount(updateid2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select nvl(likes,0),nvl(dislike,0) from updates where updateid=:updateid", {"updateid": updateid2}) for i, j in cur: list1 = [i, j] return list1 finally: cur.close() con.close()
def insert_details(user1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("insert into user_details values('" + user1.get_username() + "','" + user1.get_password() + "','" + user1.get_name() + "','" + user1.get_surname() + "','" + user1.get_gender() + "','" + user1.get_city() + "','" + user1.get_relationship_status() + "')") finally: cur.close() con.commit() con.close()
def showupdates(updateid1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select updates,nvl(likes,0),nvl(dislike,0),u1.name,u1.username from updates u inner join user_details u1 on u.username=u1.username and updateid=:updateid", {"updateid": updateid1}) for i, j, k, l, m in cur: list1 = [i, j, k, l, m] return list1 finally: cur.close() con.close()
def reject(username1, username2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "delete from request_status where username=:username and friend_username=:friendname", { "username": username1, "friendname": username2 }) finally: cur.close() con.commit() con.close()
def getupdates(username5): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list1 = [] cur.execute( "select nvl(updateid,0) from updates where username=:username", {"username": username5}) for i in cur: list1.append(int(i[0])) return list1 finally: cur.close() con.close()
def edit_profile(username, user): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute("update user_details set name='" + user.get_name() + "',surname='" + user.get_surname() + "',gender='" + user.get_gender() + "',city='" + user.get_city() + "',relationship_status='" + user.get_relationship_status() + "' where username='******'") finally: cur.close() con.commit() con.close()
def getlike(username1, updateid1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select count(*) from like_dislike where username=:username and updateid=:updateid", { "username": username1, "updateid": updateid1 }) for i in cur: return int(i[0]) finally: cur.close() con.close()
def getlikestatus(username3, updateid3): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select likestatus from like_dislike where username=:username and updateid=:updateid", { "username": username3, "updateid": updateid3 }) for i in cur: return i[0] finally: cur.close() con.close()
def showcomments(updateid2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list1 = [] cur.execute( "select u.username,u.name,c.comments from comments c inner join user_details u on u.username=c.username and updateid=:updateid", {"updateid": updateid2}) for i, j, k in cur: list1.append(i) list1.append(j) list1.append(k) return list1 finally: cur.close() con.close()
def get_username_password(username1, password1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select username,password from user_details where username=:username and password=:password", { "username": username1, "password": password1 }) for i, j in cur: return 1 return 0 finally: cur.close() con.close()
def approvelist(username4): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list2 = [] cur.execute( "select u.username,u.name,u.city from user_details u inner join request_status r on r.friend_username=u.username and r.username=:username and r.status='Pending'", {"username": username4}) for i, j, k in cur: user4 = user_details() user4.set_username(i) user4.set_name(j) user4.set_city(k) list2.append(user4) return list2 finally: cur.close() con.close()
def approve(username1, username2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur2 = DBConnectivity.create_cursor(con) cur.execute( "update request_status set status='Approved' where username=:username and friend_username=:friendname", { "username": username1, "friendname": username2 }) cur2.execute("insert into request_status values('" + username2 + "','" + username1 + "','Approved')") finally: cur.close() cur2.close() con.commit() con.close()
def status_update(user1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur2 = DBConnectivity.create_cursor(con) cur.execute("select nvl(max(updateid),0) from updates") for i in cur: v1 = int(i[0]) + 1 user1.set_updateid(v1) cur2.execute( "insert into updates(updateid,updates,username) values('" + str(user1.get_updateid()) + "',:updates1,'" + user1.get_username() + "')", {"updates1": user1.get_updates()}) finally: cur.close() cur2.close() con.commit() con.close()
def viewfriends(username3): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list1 = [] cur.execute( "select u.username,u.name,u.city from user_details u inner join request_status r on r.friend_username=u.username and r.username=:username and r.status='Approved'", {"username": username3}) for i, j, k in cur: user3 = user_details() user3.set_username(i) user3.set_name(j) user3.set_city(k) list1.append(user3) return list1 finally: cur.close() con.close()
def search_friends(value1): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list2 = [] value1 = value1.lower() cur.execute( "select username,name,surname,city from user_details where lower(username) like '%" + value1 + "%' or lower(name) like '%" + value1 + "%' or lower(surname) like '%" + value1 + "%'") for i, j, k, l in cur: user5 = user_details() user5.set_username(i) user5.set_name(j) user5.set_surname(k) user5.set_city(l) list2.append(user5) return list2 finally: cur.close() con.close()
def get_profile(username2): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list1 = [] cur.execute( "select username,name,surname,gender,city,relationship_status from user_details where username=:username", {"username": username2}) for i, j, k, l, m, n in cur: user2 = user_details() user2.set_username(i) user2.set_name(j) user2.set_surname(k) user2.set_gender(l) user2.set_city(m) user2.set_relationship_status(n) list1.append(user2) return list1 finally: cur.close() con.close()