Sometimes, pure SQL isn't enough to manipulate data. Learn how to integrate Python with MySQL. Included is a tutorial on running queries in Python, manipulating data pulled from queries, and interacting with database objects.
- [Instructor] So far we found the mean accident severity…for motorcycle accidents, but not the median.…As I mentioned before, MySQL doesn't have…a built in way to find median values.…And doing it using select statements…lead to a nasty message, sub queries upon sub queries.…Fortunately, there's an easier way using python…to extract the data from our database…manipulating it to find the median…and then adding the data back in.…Before we create our script,…we'll have to download a python module,…that will let us connect to MySQL.…So open up a command prompt,…and we'll use the python pip module to install pymysql.…
To do that you type python and -m,…to indicate you want to use a module,…then the pip module,…then install pymysql.…That'll take just a moment to download,…and it's installed.…Now that it's downloaded, let's get started on our script.…Open up a new document in Notepad++…and set the language to python.…We need to get started by importing…the pymysql module we just downloaded.…So I'll import pymysql.…
Next, we'll need to connect to our database…
- Strengths and weaknesses of MySQL
- Creating a database
- Joining data sets
- Integrating Python with MySQL
- Searching a database
- CRUD operations
- Performing calculations
Skill Level Intermediate
1. Data and MySQL in under Five Minutes
2. Create a Database
3. Join Two Datasets
4. Search a Database
Searching a database1m 51s
5. Create, Read, Update, and Delete Operations
6. Averages and Calculations
Next steps1m 1s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.