In this video I discuss error handling and logging in Python. I also show an example with a Qt application writing to a MySQL database server.
Python Logging Cookbook,
https://docs.python.org/3/howto/logging-cookbook.html
Book Powerful Python (has a good chapter on logging)
https://powerfulpython.com/book/