Thursday , December 2 2021
Home / Python / Python MySQL Installation

Python MySQL Installation

1 Python MySQL Installation

Python MySQL Database

SQL stands for Structured Query Language and is a widely used programming language for managing relational databases. Python can be used in database applications. One of the most popular databases is MySQL. Python needs a MySQL driver to access the MySQL database.

  • pip install mysql-connector-python

MySQL Database

To be able to experiment with the code examples in this course, you should have MySQL installed on your computer.

You can download XAMPP a free MySQL database at https://www.apachefriends.org/download.html. After download the XAMPP Start Apache and MySQL Server.

Test MySQL Connector

In [1]:
import mysql.connector

Note: If the above code was executed with no errors, “MySQL Connector” is installed and ready to be used.

Establishing a Connection With MySQL Server

MySQL is a server-based database management system. One server might contain multiple databases. To interact with a database, you must first establish a connection with the server. The general workflow of a Python program that interacts with a MySQL-based database is as follows:

Connect to the MySQL server.

  1. Create a new database.
  2. Connect to the newly created or an existing database.
  3. Execute a SQL query and fetch results.
  4. Inform the database if any changes are made to a table.
  5. Close the connection to the MySQL server.
In [ ]:
 

About Machine Learning

Check Also

Python MySQL Select From

5 Python MySQL Select From Python MySQL Select From Table¶To select from a table in …

Leave a Reply

Your email address will not be published. Required fields are marked *