SQLAlchemy 1.4 has modified the URL object to be immutable.
This patch makes the adjustments needed, using duck-typing
to check if the URL object is of the new style. When
requirements reach SQLAlchemy 1.4 as the minimum required
version, these conditionals should be removed in favor of
the noted option in each.
CentOS Stream 9 is shipping sqlalchemy 1.4.
Change-Id: Id2f0663b13ed0f81e91a8d44f73d8541015bf844
(cherry picked from commit f37269ae60)