Made SQL connections correctly take is_active into account