def get_all(self): try: db_config = read_db_config() conn = MySQLConnection(**db_config) cursor = conn.cursor() cursor.callproc('getAllUsers') for result in cursor.stored_results(): user = result.fetchall() users = [] for x in user: u = User() u.id = x[0] u.password = x[1] u.last_login = x[2] u.is_superuser = x[3] u.username = x[4] u.first_name = x[5] u.last_name = x[6] u.email = x[7] u.is_staff = x[8] u.is_active = x[9] u.date_joined = x[10] users.append(u) conn.commit() cursor.close() conn.close() except Error as error: print(error) except Exception as e: print(e) return users
def get_byusername(self, username): u = None try: db_config = read_db_config() conn = MySQLConnection(**db_config) cursor = conn.cursor() args = [username] cursor.callproc('getUserByUserName', args) for result in cursor.stored_results(): user = result.fetchall() for x in user: u = User() u.id = x[0] u.password = x[1] u.last_login = x[2] u.is_superuser = x[3] u.username = x[4] u.first_name = x[5] u.last_name = x[6] u.email = x[7] u.is_staff = x[8] u.is_active = x[9] u.date_joined = x[10] conn.commit() cursor.close() conn.close() except Error as error: print(error) except Exception as e: print(e) return u
def get_all(self): try: db_config = read_db_config() conn = MySQLConnection(**db_config) cursor = conn.cursor() cursor.callproc('getAllCustomerUserInfo') all_customer_info = [] for result in cursor.stored_results(): customers = result.fetchall() for x in customers: currentinfo = CustomerInfo() currentinfo.customer_id = x[0] currentinfo.work_phone = x[1] currentinfo.home_phone = x[2] u = User() u.id = x[3] u.password = x[4] u.last_login = x[5] u.is_superuser = x[6] u.username = x[7] u.first_name = x[8] u.last_name = x[9] u.email = x[10] u.is_staff = x[11] u.is_active = x[12] u.date_joined = x[13] currentinfo.set_user(u) all_customer_info.append(currentinfo) cursor.close() conn.close() except Error as error: print(error) except Exception as e: print(e) return all_customer_info