In this article, I discussed how to connect to mysql database remotely using python. It is very important for any application to store the database on the server for easy access to the data. It is quite difficult to connect to the database remotely because every service provider does not provide remote access to the MySQL database. Here I am using the MySQLdb Python module to connect to our database, which resides on any server that allows remote access.
What is MYSQLdb?
MySQLdb — it is an interface for connecting to a MySQL database server from Python. It implements the Python v2.0 database API and is built on top of the MySQL C API.
Install Packages
mysql-connector-python mysql-python
When using anaconda
conda install -c anaconda mysql-python conda install -c anaconda mysql-connector-python
else
pip install MySQL-python pip install MySQL-python-connector
Import package
import MYSQLdb
How to connect to a remote MySQL database using Python?
|
Thanks to Shaurya Uppal for helpful improvements.