The in-medium heavy quark potential from quenched and dynamical lattice QCD