database/queries: error handling for invalid queries (ints return 0, strings return 'None'