pgabrys commited on
Commit
ee9d643
·
verified ·
1 Parent(s): ca455d7

fix return

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -72,8 +72,14 @@ def get_employee_job_title(first_name:str, last_name:str)-> str: #it's import to
72
  conn = sqlite3.connect('employee_database.db')
73
  cursor = conn.cursor()
74
 
75
- return cursor.execute(f"SELECT job_title FROM employees WHERE first_name='{first_name}' AND last_name='{last_name}'")
76
- rows = cursor.fetchall()[0][0]
 
 
 
 
 
 
77
 
78
  final_answer = FinalAnswerTool()
79
 
 
72
  conn = sqlite3.connect('employee_database.db')
73
  cursor = conn.cursor()
74
 
75
+ cursor.execute(f"SELECT job_title FROM employees WHERE first_name='{first_name}' AND last_name='{last_name}'")
76
+ if len(rows) > 1:
77
+ return "Many employees with that name"
78
+ elif len(rows) == 0:
79
+ return "No employee with that name"
80
+ else:
81
+ row = cursor.fetchall()[0][0]
82
+ return row
83
 
84
  final_answer = FinalAnswerTool()
85