Rewrite get_data, unnecessary Python data processing
This commit is contained in:
		@@ -49,16 +49,20 @@ def get_data(conn):
 | 
				
			|||||||
        id = int(input("\nPlease enter student ID: "))
 | 
					        id = int(input("\nPlease enter student ID: "))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cur = conn.cursor()
 | 
					        cur = conn.cursor()
 | 
				
			||||||
        cur.execute("SELECT id, student_class, other FROM students")
 | 
					        cur.execute("""
 | 
				
			||||||
        ids = cur.fetchall()  # ids is list of tuples.
 | 
					            SELECT id, student_class, other
 | 
				
			||||||
 | 
					            FROM students
 | 
				
			||||||
 | 
					            WHERE id = ?
 | 
				
			||||||
 | 
					            """, (id,))
 | 
				
			||||||
 | 
					        data = cur.fetchone()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for tup in ids:
 | 
					        if data is not None:
 | 
				
			||||||
            if id == tup[0]:
 | 
					            data = list(data)  # SQLite returns tuples.
 | 
				
			||||||
                lis = list(tup)
 | 
					            data[2] = data[2].split()
 | 
				
			||||||
                lis[2] = lis[2].split()
 | 
					 | 
				
			||||||
                return lis
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            raise ValueError
 | 
					            raise ValueError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return data
 | 
				
			||||||
    except ValueError:
 | 
					    except ValueError:
 | 
				
			||||||
        print("\nInvalid ID, try again.")
 | 
					        print("\nInvalid ID, try again.")
 | 
				
			||||||
        return get_data(conn)
 | 
					        return get_data(conn)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user