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
Advertisements
प्रश्न
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 |
संक्षेप में उत्तर
Advertisements
उत्तर
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
