OUR OWN HIGH SCHOOL, DUBAI
Python Interface with MySQL - Worksheet-1
Grade-12
1. Sunil wants to write program in Python to insert the following details into the table named Shop in
MySQL database name Keeper.
Item Code: ‘I002’, Item Name: ‘Samsung TV’, Quantity: 10, Price: 20000
The table Shop in MySQL contains the following attributes:
• Item_code: Item Code (Integer)
• Item_name: Name of Item (String)
• Qty: Quantity of item (Integer)
• Price: Price of item (Integer)
Consider the following to establish connectivity between Python and MySQL:
• Username: admin
• Password: shopping
• Host: localhost
2. Kabir wants to write program in Python to insert the following record in the table named Student in
MySQL database SCHOOL.
• rno: Roll number (Integer)
• name: Name of the student (String)
• DOB: Date of birth (date)
• Fee: Tuition Fee (Integer)
Consider the following to establish connectivity between Python and MySQL:
• Username: root
• Password: tiger
• Host: localhost
The values of fields rno, name, DOB and fee has to be accepted by the user. Help Kabir to write the
program in Python.