Text: HW3 SQL-embedded Python for Authorization
Consider a database Company where at least the following two tables are defined. Their table schemas are:
Employee (eID INT, name TEXT, salary DOUBLE, dID TEXT, role TEXT)
Manager (eID INT, dID TEXT)
Q1 Create the database with at least 10 employees and 2 managers populated. Important: your name should be in the employee table. If not, you do not earn the credit!
Submission: screenshot showing the output of the following SQLs:
- Select * from employee;
- Select * from manager;
If your name is not in the table(s), no credit!
Q2) Write a Python code that can do the following:
1) Take an employee ID from the user
2) Display the output of the SQL: select * from employee
Submission: screenshot
Q3 - hard but essential!) Improve the Python code above that can do the following:
1) Take an employee ID from the user. Let it be idEntered
2) Get the departmentID for the given employeeID, idEntered. Let it be deptFound
3) Check if idEntered is in the table manager.
- Variable deptFound is included in SQL, if it should be included then use %s in SQL.
- Declare a variable, data_tuple = (deptFound, ) in a separate line.
- Finally, execute the query cursor.execute(query, data_tuple).
Note that the exemplified SQLs above are subject to be fixed if any syntax error occurs