Use logged_query() instead of cr.execute()