How it works...
In order to connect our Python GUI to a MySQL database, we first have to know how to connect to the MySQL server. This requires establishing a connection, and this connection will only be accepted by MySQL if we are able to provide the required credentials.
While it is easy to place strings into one line of Python code, when we deal with databases, we have to be really thoughtful because today's personal sandbox development environment could easily end up being accessible on the World Wide Web by tomorrow.
You do not want to compromise database security, and the first part of this recipe showed ways to be more secure by placing the connection credentials to the MySQL server into a separate file and, by placing this file into ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access