TKinter MySQL Database

In this lesson we are going to talk about TKinter MySQL Database, we want to learn how you can connect your tkinter application with mysql database.

 

 

First of all you need to download Wamp Server, because we are going to create our database in wamp server, after that create a database in the wamp server, you can give any name for your database, i have give tkdb.

TKinter Database
TKinter Database

 

 

 

 

Also you need to install MySQLdb, MySQLdb is an interface to the popular MySQL database server that provides the Python database API. originally MySQLdb was for Python 2.7, but there another version of MySQLdb that is called MysqlClient, and it supports Python 3.0, at the writing of this article MysqlClient supports Python 3.0 up to 3.8, you can check their Documentation for more updates.

 

 

 

This is the complete code for this lesson.

 

 

 

 

We have created a button with a label, because we want to check mysql database connectivity.

 

 

 

Using this code we can connect our tkinter application to mysql database, you need to give host, username, password and database name in the parameters.

 

 

 

 

Run the complete code and click on the button this will be the result.

TKinter MySQL Database
TKinter MySQL Database
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.