chore: fix deprecation warnings for SQLALchemy URL (#23770)

This commit is contained in:
Sebastian Liebscher 2023-05-11 10:20:53 +02:00 committed by GitHub
parent e3719a1b07
commit 0788b5fdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 8 deletions

View File

@ -1947,7 +1947,7 @@ class BasicParametersMixin:
query.update(cls.encryption_parameters)
return str(
URL(
URL.create(
f"{cls.engine}+{cls.default_driver}".rstrip("+"), # type: ignore
username=parameters.get("username"),
password=parameters.get("password"),

View File

@ -314,7 +314,7 @@ class ClickHouseConnectEngineSpec(ClickHouseEngineSpec, BasicParametersMixin):
if not url_params.get("database"):
url_params["database"] = "__default__"
url_params.pop("encryption", None)
return str(URL(f"{cls.engine}+{cls.default_driver}", **url_params))
return str(URL.create(f"{cls.engine}+{cls.default_driver}", **url_params))
@classmethod
def get_parameters_from_uri(

View File

@ -200,7 +200,7 @@ class DatabricksNativeEngineSpec(DatabricksODBCEngineSpec, BasicParametersMixin)
query.update(cls.encryption_parameters)
return str(
URL(
URL.create(
f"{cls.engine}+{cls.default_driver}".rstrip("+"),
username="token",
password=parameters.get("access_token"),

View File

@ -265,7 +265,7 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
] = None,
) -> str:
return str(
URL(
URL.create(
"snowflake",
username=parameters.get("username"),
password=parameters.get("password"),

View File

@ -36,7 +36,7 @@ def test_odbc_impersonation() -> None:
from superset.db_engine_specs.drill import DrillEngineSpec
url = URL("drill+odbc")
url = URL.create("drill+odbc")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["DelegationUID"] == username
@ -52,7 +52,7 @@ def test_jdbc_impersonation() -> None:
from superset.db_engine_specs.drill import DrillEngineSpec
url = URL("drill+jdbc")
url = URL.create("drill+jdbc")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["impersonation_target"] == username
@ -68,7 +68,7 @@ def test_sadrill_impersonation() -> None:
from superset.db_engine_specs.drill import DrillEngineSpec
url = URL("drill+sadrill")
url = URL.create("drill+sadrill")
username = "DoAsUser"
url = DrillEngineSpec.get_url_for_impersonation(url, True, username)
assert url.query["impersonation_target"] == username
@ -86,7 +86,7 @@ def test_invalid_impersonation() -> None:
from superset.db_engine_specs.drill import DrillEngineSpec
from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError
url = URL("drill+foobar")
url = URL.create("drill+foobar")
username = "DoAsUser"
with pytest.raises(SupersetDBAPIProgrammingError):