Forums

Flask, MySQL, and Git

I'm just starting to learn to program and followed parts of PythonAnywhere's tutorial for connecting a MySQL database to a Flask application, available at https://blog.pythonanywhere.com/121/. However, the tutorial actually indicates that one should push the files using Git to a version control system; the one I'm using is GitHub. This exposes our database username, password, etc., to the public, and so I was wondering what we should do in order to obscure those details. Should we create some sort of environmental variable on the PythonAnywhere server? And if so, how would one go about doing so?

Sure -- you can use environmental variables to keep your secrets unexposed (mind that the tutorial is only a tutorial with some sample code; you could use a private repository on GitHub as well, I suppose). We have a help page on that.