Helper function for debugging sql queries