Create MySQL Database and Connection in Python:
In the previous blog, we learn about how to install pymysql and Xampp. Both functionalities are required to create MySQL database and connection in Python. |
(1) Open the Xampp control panel and press the Apache and MySQL start button as shown below.


(2) If Apache and MySQL are highlighted in green color it means they start working as shown below.

(3) Now open your browser and type “http://localhost/phpmyadmin/“. The below interface is getting opened as shown below.

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it. |
(4) Open PyCharm code editor, create a new Python file in it, and import library pymysql. For creating a connection pass three parameters i.e. hostname, user name, and password. After that write a query for creating a database as shown below. (For example, we create a database named Employee).

(5) Now open localhost/phpmyadmin in the browser and you see that the Employee database is created as shown below.

Comments (No)