English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Write the Python script to display all the records of the following table using fetchmany(). Icode ItemName Rate 1003 Scanner 10500 1004 Speaker 3000 1005 Printer 8000 1008 Monitor 15000 - Computer Science

Advertisements
Advertisements

Question

Write the Python script to display all the records of the following table using fetchmany().

Icode ItemName Rate
1003 Scanner 10500
1004 Speaker 3000
1005 Printer 8000
1008 Monitor 15000
1010 Mouse 700
Answer in Brief
Advertisements

Solution

Database : supermarket
Table : electronics
Python Script:
import sqlite3
connection = sqlite3.connect
(”supermarket. db”)
cursor = connection.cursor()
cursor.execute
(“SELECT * FROM electronics “)
print(“Fetching all 5 records :”)
result = cursor.fetchmany(5)
print(*result,sep=” \ n”)

Output:
Fetching all 5 records :
(1003,’Scanner’ ,10500)
(1004,’Speaker’,3000)
(1005,’Printer’,8000)
(1008,’Monitor’,15000)
(1010,’Mouse’,700)

shaalaa.com
  Is there an error in this question or solution?
Chapter 15: Data manipulation through SQL - Evaluation [Page 318]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 15 Data manipulation through SQL
Evaluation | Q 2. | Page 318
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×