1.

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

Answer»
IcodeItem NameRate
1003Scanner10500
1004Speaker3000
1005Printer8000
1008Monitor15000
1010Mouse700

import sqlite3

connectoin = sqlite3.connect(“company.db”) cursor = connection.cursor() cursor.execute(“Select * from product”)

print(“Displaying Records”) result = cursor.fetchmany(5)

print(*result, Sep = “\n”) 

Output:

Displaying records (1003, ‘Scanner’ , 10500) 

(1004, ’Speaker’ , 3000)

(1005, ‘Printer’ , 8000)

(1008, ’Monitor’ , 15000)

(1010, ‘Mouse’ , 700)



Discussion

No Comment Found