Esempio n. 1
0
 def get_one_by_id(self, id):
     if id == None or id < 0:
         return None
     self.cursor.execute("SELECT * from projekt.user where id=%d ;" % id)
     records_user = self.cursor.fetchone()
     if records_user == None:
         return None
     new_user = User()
     new_user.id = records_user[0]
     new_user.name = records_user[1]
     new_user.surename = records_user[2]
     new_user.login = records_user[3]
     new_user.password = records_user[4]
     new_user.lastlogin = records_user[5]
     new_user.lastlogintime = records_user[6]
     return new_user
Esempio n. 2
0
 def get_all(self):
     self.cursor.execute("SELECT * from projekt.user ;")
     records_user = self.cursor.fetchall()
     if records_user == None:
         return None
     user_list = []
     for user in records_user:
         new_user = User()
         new_user.id = user[0]
         new_user.name = user[1]
         new_user.surename = user[2]
         new_user.login = user[3]
         new_user.password = user[4]
         new_user.lastlogin = user[5]
         new_user.lastlogintime = user[6]
         user_list.append(new_user)
     return user_list
Esempio n. 3
0
 def user_select(self, login_result, pass_result):
     if login_result == None or pass_result == None:
         return None
     user_select_query = "SELECT * from projekt.user where login=%s and password=%s"
     parameters = (str(login_result), str(pass_result))
     self.cursor.execute(user_select_query, parameters)
     selected_user = self.cursor.fetchone()
     if selected_user != None:
         new_user = User()
         new_user.id = selected_user[0]
         new_user.name = selected_user[1]
         new_user.surename = selected_user[2]
         new_user.login = selected_user[3]
         new_user.password = selected_user[4]
         new_user.lastlogin = selected_user[5]
         new_user.lastlogintime = selected_user[6]
         return new_user
     else:
         return None