Room to grow

While the projection specification that we set for ourselves is fulfilled, there is more that can be done on this program to make it more serviceable in a production environment. Some areas that you might look at for further practice are:

  • Set the host, database, username, and password from command-line options. You will naturally need to error-check each of them. You will probably want to use the getpass module to accept the password in production environments.
  • Set an option for the column variable and testing whether that column exists in the chosen database.
  • Set up error-checking for the results itself.

The world database has a few other tables besides City. Can you aggregate their records in Python without using a JOIN statement?

Get MySQL for Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.