MySQL Connector/Python is a driver released by Oracle themselves to make it easier to connect to a MySQL database with Python. MySQL Connecter/Python supports all versions of Python 2.0 and later, also including versions 3.3 and later.
To install MySQL Connector/Python simply use pip to install the package.
pip install mysql-connect-python --allow-external mysql-connector-python
Connecting to database and committing to it is very simple.
import mysql.connector connection = mysql.connector.connect(user="username", password="password", host="127.0.0.1", database="database_name") cur = connection.cursor() cur.execute("INSERT INTO people (name, age) VALUES ('Bob', 25);") connection.commit() cur.close() connection.close()
Recommended Python Training
Course: Python 3 For Beginners
Over 15 hours of video content with guided instruction for beginners. Learn how to create real world applications and master the basics.