Learn how to connect to a MySQL database, create tables, insert and fetch data in Python using MySQL connector.
MySQL is one of the most popular open source relational database management systems (RDBMS) out there, it is developed, distributed and supported by Oracle Corporation now.
In this tutorial, you will use MySQL connector Python library to:
To get started, first you need to have a MySQL server instance running in your machine, if you’re on Windows, I suggest you get XAMPP installed. If you’re on a Linux machine (Ubuntu or similar), check this tutorial. If you’re on MacOS, run through this tutorial to get MySQL installed.
Second, let’s install MySQL connector Python library as well as tabulate module:
pip3 install mysql-connector-python tabulate
We’ll be using tabulate module optionally to output fetched data in a similar way to regular MySQL clients.
#python #mysql #database