Connect MySQL DB using python
Connect MySQL db using python script. Use config.ini file for configurations.
We are going to see how to retrieve all records from MySQL table using python script.
Prerequisite:
1] Python [2.7 or 3.X] : [https://www.python.org/downloads/]
2] MySQL install on your system :
windows user [https://www.mysql.com/downloads/]
Ubuntu user [sudo apt-get install mysql-server]
3] pip install mysql-connector
Let’s write program: We required two files to connect MySQL and retrieve data
1] connect_mysqldb.py : Containing the python code
2] config.ini : MySQL DB configurations like hostname, username, password, port, etc.
Conclusion :
Thanks for reading this article. I hope it is useful for you guys. Still there are many ways remain to connect and retrieve data from database. If you are facing any issue please let me know.