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' created successfully!")
```
2. b. Set connection with `mysql.connector.connect`:
```python
# Connect _________ __________ _____ _______ ________ ______ ____.
__________ _________ _____ ____ ___ ____ _____.
___ __________ ________ _____ __________.
_____ _____ _________ __________ __________ ___.
_________ __________ ________ _______ __________ _______ ____ __________ ______.
_________ ____ ______ __________ ___ ________ ____ _________ _____.
___ _____ _____ __________ _______.
______ _________ _______ ____ _______ __________.
__________ _______ _______ ____ _______ ________ _______ ________ __________.
__________ ___ ______ ____ _____ ____ _____ _____ _______ ______ ________.
___ _____ ______ _______ _______ ____ _______ ___ _________ _________ __________ _________.
_________ _______ ___ ______ ______ ______ _________ __________ ___ ______.
________ ___ __________ _____ _________ _______.
_________ __________ ______ _________ ___ ____.
_________ _______ _____ ________ ___.
_________ ___ _______ _____ ____ _________ _____ _____.
______ _______ ___ _______ ________ ________ ________ _______ _________ ____.
________ _________ ____ _____ __________ ___ _______ ________ _____.
_______ ___ ____ ____ __________ ________ ______ ____ ________ ________ ____.
______ _________ _____ __________ ___ ___ _______ __________ ____ _______ ________ ______.
_____ _________ _______ _______ _______ ______.
___ ____ _______ _______ ______ _________ _____.
____ _____ _________ ___ ___ ______.
______ ________ ___ ___ _______ ______.
____ ____ __________ ______ _________ ________ __________ ______ _________ _______ ________ _______.
_______ ____ _________ _____ __________.
__________ __________ _______ ________ ________ _______.
_______ ______ _________ ___ ________ _____ ____ _____ ________ _________.
__________ ____ ______ ____ ______ ____ _____ _____ ____ ___ _____.
_____ ___ _______ ___ _______ _________ ______ ______ _______ __________ ________.
________ _________ ________ _____ _______ ____ ______ ______ __________ _______ _______.
________ ____ _______ __________ ________.
________ ____ _________ _________ ___ ________ _______ __________ _____ _________.
_____ ___ ______ ______ _____ _____.
__________ ______ ____ ______ ____ ______ ______ ______ ____ __________.
___ _______ __________ _______ ________ __________.
________ _______ ________ _________ ______ _____.
_______ ______ __________ _____ ______ _________ _____.
_______ ___ ________ ___ ______ ______ _________ _____ ______ _________ ________.
____ ____ __________ ______ ___ _________ ______ ______.
______ ___ ______ ____ ______ _________ _________ __________.
__________ _________ ___ ________ _______ _________ _________ _________.
___ ____ __________ _____ ___ ________ _________ _____ __________.
______ ______ _____.
Get Full Answer on WhatsApp