Write Program to perform following tasks (10 Marks)
a. Create a database PRODUCT_SELECTION_DB
b. Set connection with mysql.connector.connect.
c. Create a table PRODUCT _SELECTION in database PRODUCT_SELECTION_DB with
following data PRODUCT_NAME,PRODUCT_PRICE, MANUFACTURER, EXPIRY_DATE.
d. change table structure / (add, edit, remove column of a table) at run time
i. add a column address in the PRODUCT_SELECTION table.
ii. execute SQL INSERT statement to create a record into PRODUCT _SELECTION table
iii. run the query to updates all the records having EXPIRY_DATE as 31-Dec-2022 and
increase PRICE of all the PRODUCTS by 10% of PRODUCT_PRICE.
iv. delete all the records from PRODUCT _SELECTION Table where EXPIRY_DATE is
before 31-Dec-2022.
Below are Python programs to accomplish the tasks outlined using the `mysql.connector` module for database interaction and SQL queries:
```python
import mysql.connector
# Establishing connection to MySQL
try:
connection = mysql.connector.connect(
host="your_host",
user="your_username",
password="your_password",
database="PRODUCT_SELECTION_DB"
)
cursor = connection.cursor()
# Creating a table PRODUCT_SELECTION in database PRODUCT_SELECTION_DB
create_table_query = """
CREATE TABLE _____ _________ ___ _____ ____ _________ _________ ______ ________ _____ ___.
_____ _________ _____ ______ ___ ___.
__________ ____ _____ _______ _____.
_____ ______ _________ __________ ____ ________ _______ ___ _____ _______ ____.
_________ _______ _________ ___ ________ _________ _______.
________ __________ __________ ______ ___ __________ _____ _____ _______ __________ _______.
__________ ____ _______ _____ _________ __________ ____ __________ ________ _______ ___ ____.
__________ ___ ___ ______ ______ ________ ____.
________ ___ _________ _____ ___ ___ ____ ______ _________ __________ ________ ______.
______ _________ _______ _____ ____ _____ ________ _____.
____ _________ _______ _______ ____ _________ ________ _______ _______ _________.
_________ _____ _____ __________ _________ _______ ____ _________.
______ ______ ___ _________ _______ _________ _______ ____ ______.
__________ ___ ________ ______ ________ _____ _____ ____ ________ _______.
_________ _________ ________ ____ _______ ______ ___ ________ _______ __________ ____.
_____ _________ ________ ________ _________ ________.
______ ____ _________ _____ ________ ______ ___ ________.
_______ _________ _________ _______ _______ _________ ___ ____ ______ _______.
_______ ____ __________ ___ ________.
_______ ______ ___ ____ ___ _________.
_________ _______ _________ ________ ___ ______.
___ ____ _________ ________ ________.
_____ _________ __________ ____ _________ __________ ______ _____.
______ ___ ____ _______ _______.
__________ _____ _________ ______ __________.
_____ ____ _____ _______ _________ _____ _________ ______ __________.
_____ ______ ______ __________ ____ _____ _____ _______ _____ ______ ________ ______.
_________ ____ ____ _____ ___.
__________ ___ ___ __________ _____ _____.
___ ______ ___ __________ ________ ______ __________ _________.
______ _______ ______ ______ _____ _________ ____ ________ _____ ___.
________ ________ __________ __________ ____ ___ _____ ______ ____ ______.
____ _________ ______ _______ ______ ______ __________.
______ ________ ______ ____ _____ _________ ______ _____.
__________ ____ ________ ___ __________ _____.
_________ _____ ______ ________ __________ ________ _________ ________ ______ __________.
___ ______ ___ _______ ______ ______ ______ ______ _____ ________ __________ ________.
___ __________ _________ ___ ___ _______ _________ ____ _________ ______.
____ ____ __________ _______ ________ ___ _____ _____.
______ ________ _______ ___ ________ _________ _______ __________.
______ _____ ________ _________ ___ _________ ____ ________ _______ ___.
_________ ______ __________ ___ _______ _________.
_______ _______ ___ ____ __________ ____ _________.
____ _________ ______ ____ _______ __________ ____ ________.
Get Full Answer on WhatsApp