Attempt the following
I) Write Program to perform following tasks
a. Create a database SELECTION DB
b. Set connection with mysql.connector.connect.
с. Create a table STUDENT SELECTION in database SELECTION DB with following data FIRST NAME LAST NAME,AGE,GENDER, SCORE.
d. change table structure / (add, edit, remove column of a table) at run time
i. add a column address in the STUDENT SELECTIONtable.
ii. execute SQL INSERT statement to create a record into STUDENT SELECTION table
iii. run the query to updates all the records having GENDER as 'M', and increase AGE of all the males by one year.
iv. delete all the records from STUDENT_SELECTION Table where AGE is less than 18.
Here is how you can implement the tasks in Python using MySQL and MySQL connector:
### Step-by-step solution for the tasks:
1. a. Create a database SELECTION DB:
```python
import mysql.connector
# Establish connection to MySQL server
connection = mysql.connector.connect(
host="localhost",
user="your_username",
password="your_password"
)
cursor = connection.cursor()
# Create database SELECTION_DB
cursor.execute("CREATE DATABASE IF NOT EXISTS SELECTION_DB")
print("Database 'SELECTION_DB' ___ _______ ____ _____ _______ _______ _____ ______ _________ _________.
____ ____ ____ __________ _____ ____ ____.
_______ ___ _____ _________ _____.
_______ _____ _____ __________ _____ ____.
_______ ___ __________ _________ ______.
_________ ____ _____ ______ _____ ___.
___ _____ _________ ___ _________ ___ __________ ________ ____ _____ ________ ____.
________ _____ _________ __________ ___ ______ ___ _______.
__________ _______ __________ _____ ___ ______ ___.
_________ ____ ________ _______ _____ ____ ______ ________ _______ __________ ________ ____.
________ ________ _____ ____ _____ ________ ___ _____ ________ __________ ________.
_____ _________ ____ __________ _____.
____ ___ __________ ______ __________.
___ _________ ______ __________ ______ ___ __________ ___ _______ ____.
___ ______ ___ ____ _______ _________ ______.
__________ ____ ________ __________ _______ ___ _______ ______.
__________ ___ _________ ________ _________ _________.
________ ___ ___ _______ ___ _________ ________ _____ _______.
_______ _____ __________ __________ __________ ___.
__________ __________ ______ ______ ______ _____.
___ _______ _______ _____ _________ __________.
_______ ________ ____ __________ ____ ___.
____ _______ ____ __________ _________ _________ _________ __________.
______ __________ ________ ____ ______.
____ _______ _______ ____ ________ ___ ______ _____ __________ _______ _______.
______ __________ ________ _____ _________ ___ ______ ____ ______ _____ ______.
____ _________ _________ ______ ______ ________ ___ _________ ______ ________ _________.
___ ________ _____ ________ ____ ______ ____ ____ _______ ________.
__________ ____ _____ __________ ____ _____ _________.
_____ ______ ____ ____ _______ ____ ______ _____ ______ ______ _________ _________.
________ _____ ________ _________ ________ ____ ________ ____ ___ _______ ________.
___ ____ _____ _______ _____.
________ _______ ____ _________ __________ ______ ____.
_________ ____ ______ __________ _______ _________ ____ ________ _____ ___ ___ _____.
________ _________ ___ _______ ____ ______ _____.
_______ ___ _______ ______ ______ _________ ________.
___ _________ _________ _________ _________ ______.
_____ ____ __________ __________ ________ ____ ________.
________ _________ _____ _____ _____ _________ ____ _______ ______ ________ _______.
_______ __________ _________ _______ __________ _________ ____ ___ ___ ________ ____ ________.
___ ___ _________ ___ _______ ________ _________ ___.
___ _____ ____ ________ __________ ______ _____ _____ _______.
____ ______ ______ ________ _________ _______.
___ ________ _______ ______ ___ ______ __________ ___ _____ __________.
___ _____ ___ _________ _______ ________ __________ _______ _______.
Get Full Answer on WhatsApp