1.
A table named Event in VRMALL database has the following structure:
Field Type
EventID int(9)
EventName varchar(25)
EventDate date
Description varchar(30)
Write the following Python function to perform the specified operations:
Input_Disp(): to input details of an event from the user and store into the table Event. The
function should then display all the records organised in the year 2024.
Assume the following values for Python Database Connectivity
Host-localhost, user-root, password-tiger
2. A table, named ELECTRONICS, in the PRODUCTDB database, has the
following
structure:
Field Type
productID int(11)
productName varchar(20)
price float
stockQty int(11)
Write the following Python function to perform the specified operation:
AddAndDisplay(): To input details of a product and store it in the table
ELECTRONICS. The function should then retrieve and display all records from the
ELECTRONICS table where the price is greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost
User: root
Password: Electro123
1. Sunil wants to write a function ADRecord in Python to insert a record and
display the records of the items whose price is between 200 to 300 in the table
named Stall in MySQL database named Maintain .
The table Stall in MySQL contains the following attributes:
_code: item code (integer)
_name: name of item (string)
Quan: quantity of the item (integer)
Amount : price of item (integer)
Consider the following to establish connectivity between Python and
MySQL:
Username - Administrator
Password - market
Host – localhost
2. Raman has created table named NATIONALSPORTS in MYSQL database,
SPORTS :
Each record contains the following fields:
∙ GameID(Game number )- integer
∙ Gamename(Name of game) - string
∙ DOG(Date of Game) – Date
∙ Venue(Venue of game) – decimal
Note the following to establish connectivity between Python and MySQL:
∙ Username - root
∙ Password – KVR@321
∙ Host – localhost
Raman , now wants to display all records of venue “Hyderabad”. Help him to
write the python program.
1. A table, named STUDENT, in SCHOOL database, has the following structure:
Field Type
Rollno integer
Name string
Class integer
Mark integer
Write the following Python function to perform the specified operation:
AddStudent(): To input details of a student and store it in the table STUDENT.
The function should then retrieve and display all records from the STUDENT table where the
Mark is greater than 80.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password:root
2. Kabir wants to write a program in Python to insert the following record in the
table named Student in MYSQL database, SCHOOL:
rno(Roll number )- integer
name(Name) - string
DOB (Date of birth)-Date
Fee - float
Note the following to establish connectivity between Python and MySOL.:
Username - root
Password - tiger
Host - localhost
The values of fields rno, name, DOB and fee has to be accepted from the user. Help Kabir to
write the program in Python.
1. A table, named PRODUCT, in PRO_DB database, has the following structure:
Attribute Name Data Type
P.T.: PID int(6)
PNAME Varchar(20)
COMPANY Varchar(20)
PRICE Float
Write the following Python function to perform the specified operation:
AddNewProduct): To input details of Product and store it in the table PRODUCT. The
function should then retrieve and display all records from the PRODUCT table where the
Price is less than 250.
Assume the following for Python-Database connectivity:
(Host: localhost, User: root, Password: Time)
2. A table named student, in school database, has the following structure:
RollNo – integer
Name – string
Class – integer
Marks – integer
Write the following Python function to perform the specified operation:
DataDisplay(): To input details of student and store it in the table. The function should then
retrieve and displays only those records who have marks greater than 75.
Note the following to establish connectivity between Python and MYSQL:
Username is root , Password is tiger.
1. Kishan wants to write a program in Python to insert the following record in the
table named Flight in MYSQL database JNV:
● Flno (Flight number)-varchar
● Source (source)- varchar
● Destination (Destination)-varchar
● Fare (fare)-integer
Note the following to establish connectivity between Python and MySQL:
● User name-root
● Password – NVS@123
● Host-localhost
The values of fields Flno, Source, Destination and Fare has to be accepted from the user.
Help Kishan to write the program in Python.
2. Suman has created a table named Game in MYSQL database Sports:
● GID (Game ID)-integer
● Gname( Game name)-varchar
● No_of_Participants (number of participants)- integer
Note the following to establish connectivity between Python and MySQL:
● Username: root
● Password: NVS@123
● Host: localhost
Suman, now wants to display the records of students whose number of participants are more
than 10, Help Suman to write the program in Python.
1. Aarya has created a table named Emp in MySQL:
EmpNo – integer
EmpName – string
Age– integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
● Username - root
● Password - tiger
● Host - localhost
● The Emp table exists in a MYSQL database named company.
● The details (EmpNo, EmpName, Age and Salary) are to be acceptedfrom the user.
Aarya wants to display All Records of Emp relation whose age is greater than 55. Help Aarya
to write program in python.
2. A table, named INVENTORY, in SHOP database, has the following structure:
Field Type
itemNo int
itemName varchar(15)
price float
qty int
Write the following Python function to perform the specified operation:
addRec(): To input details of an item and store it in the table INVENTORY. The function
should then retrieve and display all records from the INVENTORY table where the price is
greater than 150.
Assume the following for Python-Database connectivity:
Host: localhost, User: root, Password: Chetan