Advertisements
Advertisements
प्रश्न
Consider the following table Supplier and item. Write a python script for the following Question?
| SUPPLIER | ||||
| Suppno | Name | City | Icode | SuppQty |
| S001 | Prasad | Delhi | 1008 | 100 |
| S002 | Anu | Bangalore | 1010 | 200 |
| S003 | Shahid | Bangalore | 1008 | 175 |
| S004 | Akila | Hydrabad | 1005 | 195 |
| S005 | Girish | Hydrabad | 1003 | 25 |
| S006 | Shylaja | Chennai | 1008 | 180 |
| S007 | Lavanya | Mumbai | 1005 | 325 |
Display Name, City, and Itemname of suppliers who do not reside in Delhi.
Advertisements
उत्तर
Coding:
import sqlite3
connection = sqlite3.
connection/’ABC.db”)
cursor = connection, cursor ()
sqlcmd=”””(“SELECT SUPPLIER. Name,SUPPLIER.City,Item.ItemName FROM SUPPLIER,Item WHERE SUPPLIER.City NOT IN(“Delhi”) and SUPPLIER.Icode=Item.Icode” ” ”
cursor, execute(sqlcmd)
result = cursor.fetchall()
print(” Suppliers who do not reside in Delhi:”)
for r in result:
print(r)
conn.commit ()
conn, close ()
Output:
Suppliers who do not reside in Delhi:
(‘ Anu’ / Bangalore’/Mouse’)
(‘Shahid7,’Bangalore7,’Monitor’)
(‘Akila’/Hydrabad’,’Printer’)
(‘Girish’/Hydrabad’/Scanner’)
(‘Shylaja’/Chennai’/Monitor’)
(‘ La vanya’/ Mumbai’/ Printer’)
