Use click.secho to print unicode strings

Using plain print() causes a UnicodeEncodeError if the text cannot be
encoded using the encoding of the target stream (stdout or stderr).
click.secho encodes unicode strings with errors='replace', so it is more
fault-tolerant.
Print SQL commands when --debug is set
Ignore python cache files
Sanitize filename