Using Python to Create a Table in MySQL
July 18, 2023
This one’s for all of you data analysts out there.
And this is literally the coolest thing I’ve done with Python so far.
I’ve found a library that allows me to access my local MySQL server using Python.
Ain’t that cool? Or is that just me?
Anyway, I’m working on a project that scraps data from this dorky blog and randomly selects a blog post to email me every day.
This project is cool for four reasons:
- I’m creating a database in MySQL
- I’m adding data into MySQL using Python
- I’m creating an automated email system to send daily emails to myself
- The finished product will automate my data science learning project
That’s a win-win-win-win right there.
I’m not gonna go in-depth on any code today, but check out the Python script below. It’s my first (successful) attempt at creating a table in a MySQL database without writing a query directly in MySQL.
And in case you’re wondering which library I’m using, it’s the pymysql library…