Use Python with MySQL to read a text file and insert its data into MySQL using bulk INSERT queries. Learn about using epoch time to calculate the average execution time of those queries.
- Now that our tables are set up…it's time to insert records.…I've opened a new document in Notepad++.…And I'll set the Language to Python.…The first thing we need to do is…import the pymysql in time modules…that we'll be using later in the script.…So I'll import pymysql.…Import time.…The next step is to establish a connection to the database.…So I'll create a myConnection object.…And then use the connect method of the pymysql module…and provide the database information.…The host is localhost.…
User is root.…The password for my database is password.…And the db is shakespeare.…I also want to create a cursor object…so we can interact with the database.…I'll just call it cur.…And it's myConnection.cursor.…Now I need a list of characters.…I don't want to insert lines into the database…that are just the name of a character…so I will need to pull those character names into a list…so our program can recognize them.…
And fortunately the dataset includes…a list of the characters.…So I will open the characters.txt file…for reading.…
- 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.