Inserting records into the database

The MySQLdb module allows us to insert records into the database using the same cursor operation. Remember that the execute() method can be used for both insertion and query. Without further ado, we will change our script a bit and provide the following insert commands:

#!/usr/bin/python__author__ = "Bassim Aly"__EMAIL__ = "basim.alyy@gmail.com"import MySQLdbSQL_IP ="10.10.10.130"SQL_USERNAME="root"SQL_PASSWORD="EnterpriseAutomation"SQL_DB="TestingPython"sql_connection = MySQLdb.connect(SQL_IP,SQL_USERNAME,SQL_PASSWORD,SQL_DB)employee1 = {    "id": 1,    "fname": "Bassim",    "lname": "Aly",    "Title": "NW_ENG"}employee2 = {    "id": 2,    "fname": "Ahmed",    "lname": "Hany",    "Title": "DEVELOPER"}employee3 = {    "id": 3,    

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.