Skip to content

Commit e0f54c9

Browse files
authored
feat(trino): wrap auth strings with BasicAuthentication (#9960)
1 parent a89b689 commit e0f54c9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ibis/backends/trino/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
from functools import cached_property
88
from operator import itemgetter
99
from typing import TYPE_CHECKING, Any
10-
from urllib.parse import unquote_plus
10+
from urllib.parse import unquote_plus, urlparse
1111

1212
import sqlglot as sg
1313
import sqlglot.expressions as sge
1414
import trino
15+
from trino.auth import BasicAuthentication
1516

1617
import ibis
1718
import ibis.backends.sql.compilers as sc
@@ -309,10 +310,20 @@ def do_connect(
309310
raise ValueError(
310311
"Cannot specify both `auth` and `password` when connecting to Trino"
311312
)
313+
else:
314+
auth = password
312315
warnings.warn(
313316
"The `password` parameter is deprecated and will be removed in 10.0; use `auth` instead",
314317
FutureWarning,
315318
)
319+
320+
if (
321+
isinstance(auth, str)
322+
and (scheme := urlparse(host).scheme)
323+
and scheme != "http"
324+
):
325+
auth = BasicAuthentication(user, auth)
326+
316327
self.con = trino.dbapi.connect(
317328
user=user,
318329
host=host,
@@ -321,7 +332,7 @@ def do_connect(
321332
schema=schema,
322333
source=source or "ibis",
323334
timezone=timezone,
324-
auth=auth or password,
335+
auth=auth,
325336
**kwargs,
326337
)
327338

0 commit comments

Comments
 (0)