We need to fetch the details of employees from the database whose salaries are within a certain range in Python.
Solution:
We will use python's pymysql library to work with the database. This library provides the programmer the functionality to run MySQL query using Python.
Algorithm:
- Step 1: Take the maximum and minimum salary from the user.
- Step 2: Create a MySQL query, to select data within the range from the database. Refer: SQL tutorial for help.
- Step 3: Connect to database and run the query. Using the execute command.
- Step 4: Store all fetched employee details in row variable.
- Step 5: print details.
Python program to fetch details from the database
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer