Advertisements
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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
