CBSE · 083Class XII · 2024Section E5 marks

Question 35(or)

2 April 2024 · Computer Science (083)

(i) Give any two features of SQL.

(ii) Sumit wants to write a code in Python to display all the details of the passengers from the table flight in MySQL database, Travel. The table contains the following attributes: - F_code: Flight code (String) - F_name: Name of flight (String) - Source: Departure city of flight (String) - Destination: Destination city of flight (String)

Consider the following to establish connectivity between Python and MySQL: - Username: root - Password: airplane - Host: localhost

Answer

(i) Any two of the following: - Full form is Structured Query Language. - Is used to retrieve and view specific data from a table in a database. - Is case insensitive. - Each query in SQL ends with a semicolon (;). - It contains DDL and DML.

(ii)

python
import pymysql as pm

DB = pm.connect(host="localhost", user="root",
                password="airplane", database="Travel")
MyCursor = DB.cursor()
MyCursor.execute("SELECT * FROM flight")
Rec = MyCursor.fetchall()
for R in Rec:
    print(R)
DB.close()

Explanation

(i) Two acceptable SQL feature statements. (ii) Connects to MySQL, executes SELECT, fetches all rows, and prints them.