Challenge

Project 2

import pandas as pd
import mysql.connector

cnx = mysql.connector.connect(
host='your_host',
user='your_user',
password='your_password',
database='alumni'
)

def fetch_rows(table_name):
query = f"SELECT * FROM {table_name} LIMIT 1000"
df = pd.read_sql(query, cnx)
return df

table_names = [
'College_A_HS',
'College_A_SE',
'College_A_SJ',
'College_B_HS',
'College_B_SE',
'College_B_SJ'
]

tables_data = {}

for table_name in table_names:
df = fetch_rows(table_name)
tables_data[table_name] = df

for table_name, df in tables_data.items():
print(f"Table: {table_name}\n")
print(df)
print("\n-----------------------------------------\n")

I have uploaded the sql file below and write the python code but unable to upload the excel file

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.