How to access a MySQL database using XL Routes Static IP and PythonAnywhere
Approximate time to read: 1 min
Are you trying to connect to a MySQL Database and PythonAnywhere recommended you reach out to XLRoutes for help? You’ve come to the right place.
To make this work easiest for new users, we created an example Python application which uses a monkeypatched version of mysql-connector-python through PySocks.
You can find the example here: https://github.com/xlroutes/pymysql-example. Please read the README.md file for details on how to use the test application.
Once you have tested that locally you should be able to integrate it into your application.
You will need to install https://help.pythonanywhere.com/pages/InstallingNewModules/ the pips PySocks https://github.com/Anorov/PySocks and mysql-connector-python https://dev.mysql.com/doc/connector-python/en/.
You will also need to set the environment variable https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/ for xlroutesSTATIC_URL (found here: https://www.xlroutes.com/configuration/outbound).
Once those steps are complete, you should have the bare bones setup done.
Any issues, errors, or problems? Please write us at Support and we’ll help debug it with you to get you up and running.