Importer for TV shows CSV -> MySQL
- Reads the CSV
10k_Poplar_Tv_Shows.csv(same folder by default). - Parses
genre_idsandorigin_countrywhich are stored as arrays in the CSV. - Inserts data into the normalized MySQL schema created by
create_tv_shows_db.sql.
import_tv_shows.py— the importer script (uses SQLAlchemy + pymysql + pandas).requirements.txt— Python deps.create_tv_shows_db.sql— (already present) schema creation and transform examples.
-
Create the DB schema (if you haven't already):
- Open MySQL Workbench or mysql client and run
create_tv_shows_db.sql.
- Open MySQL Workbench or mysql client and run
-
Install Python deps (recommend a venv):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r "c:\Users\gerbi\OneDrive\Desktop\TCU\Juinor Yr\First Semester\Database\Project\Dataset\Database Program\requirements.txt"- Run the importer (example):
python import_tv_shows.py --csv "10k_Poplar_Tv_Shows.csv" --host localhost --user root --password MySecret --db tv_shows_db- --csv : path to CSV (default:
10k_Poplar_Tv_Shows.csvin current folder) - --host, --port, --user, --password, --db
- --batch : number of rows per batch (default 500)
- The script writes directly to the normalized tables and uses INSERT IGNORE / INSERT ... ON DUPLICATE KEY UPDATE.
- If your CSV contains malformed list fields, the script tries several parse strategies (json, replace single quotes, ast.literal_eval).
- The script does not populate
genres.nameorcountries.country_name— you can add those manually or with an extra mapping.