you simply can't short of modding the game itself. Best way to stop it from nuking your planets is to build a star-base and use the aux government/endearing devotion upgrade to prevent the loss of the planet. That forces whoever you are fighting against to have to come to that planet, kill the SB, and then bomb to planet to take it. As they suggested in that link, and if you want to be an eco player (as the person whining about it in the link there) the star-bases HELP you in that regard by upping your trade even higher in that planet if you get the trade ports on it.
If TEC the Hardened Cities upgrade helps, also planetary shields and upgrading the planet itself also bring down the damage to where the cannon dose nothing to you anymore.
Either that, or don't set the AI to TEC?