SQL_Python_Class12_Questions
SQL_Python_Class12_Questions
2. Which of the following is the correct method to execute an SQL query in Python?
a) `cursor.run(query)`
b) `cursor.execute(query)`
c) `cursor.exec(query)`
d) `cursor.sql(query)`
2. A company wants to store employee details in MySQL. Create a Python script to:
- Establish a database connection
- Create a table "employees" (id, name, department, salary)
- Insert sample data and retrieve all employees from the IT department.
3. Write a Python program to generate a report that lists students along with their grades, sorted in
descending order.