In this tutorial you will learn how to use a widely used database management system called MySQL in Python. You do not need any previous knowledge of MySQL to use this tutorial, but there is a lot more to MySQL than covered in this short introductory tutorial.
MySQL with Python In this tutorial you will learn how to use a widely used database management system called MySQL in Python. You do not need any previous knowledge of MySQL to use this tutorial, but there is a lot more to MySQL than covered in this short introductory tutorial. Win / Mac / Linux installers Find your favorite application in our catalog and launch it. Learn more about the benefits of the Bitnami Application Catalog.
Related course
Master SQL Databases with Python


MySQL tutorial
Data is stored in a collection of tables with each table consisting of a set of rows and columns. This is similar to how data is stored in SQLite. To interact with the data stored in tables we use a special-purpose programming language called SQL.
Step 1: Install MySQL
First you must install a MySQL driver, use the specific installation method below.
On Windows:
Install MySQLdb using the installer.
On Linux:
Install MySQLdb using:
depending on your version.
On Mac:
Follow the installation instructions from stackoverflow
MySQL server has to be running before going to the next step.
Step 2: Setup the database

Make sure you have database access, from the command line type:
MySQL will then ask your password. Type these commands:
We go on the create the table:
Then we can insert data into the table (these are SQL queries):
You can now grab all records from the table using a SQL query:
Mysql Python Call Stored Procedure
Step 3: Getting the data from Python
You can access the database directly from Python using the MySQLdb module.
Output:
Mysql Connector Python Mac
Related course
Master SQL Databases with Python
