20
20
from .errors import NotSupportedError
21
21
from .utils import handle_ydb_errors
22
22
from .utils import maybe_get_current_trace_id
23
+ from .utils import prepare_credentials
23
24
24
25
25
26
class IsolationLevel (str , Enum ):
@@ -69,13 +70,15 @@ def __init__(
69
70
port : str = "" ,
70
71
database : str = "" ,
71
72
ydb_table_path_prefix : str = "" ,
72
- credentials : ydb .AbstractCredentials | None = None ,
73
+ protocol : str | None = None ,
74
+ credentials : ydb .Credentials | dict | str | None = None ,
73
75
ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
74
76
** kwargs : dict ,
75
77
) -> None :
76
- self .endpoint = f"grpc://{ host } :{ port } "
78
+ protocol = protocol if protocol else "grpc"
79
+ self .endpoint = f"{ protocol } ://{ host } :{ port } "
80
+ self .credentials = prepare_credentials (credentials )
77
81
self .database = database
78
- self .credentials = credentials
79
82
self .table_path_prefix = ydb_table_path_prefix
80
83
81
84
self .connection_kwargs : dict = kwargs
@@ -170,7 +173,8 @@ def __init__(
170
173
port : str = "" ,
171
174
database : str = "" ,
172
175
ydb_table_path_prefix : str = "" ,
173
- credentials : ydb .AbstractCredentials | None = None ,
176
+ protocol : str | None = None ,
177
+ credentials : ydb .Credentials | None = None ,
174
178
ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
175
179
** kwargs : dict ,
176
180
) -> None :
@@ -179,6 +183,7 @@ def __init__(
179
183
port = port ,
180
184
database = database ,
181
185
ydb_table_path_prefix = ydb_table_path_prefix ,
186
+ protocol = protocol ,
182
187
credentials = credentials ,
183
188
ydb_session_pool = ydb_session_pool ,
184
189
** kwargs ,
@@ -333,7 +338,8 @@ def __init__(
333
338
port : str = "" ,
334
339
database : str = "" ,
335
340
ydb_table_path_prefix : str = "" ,
336
- credentials : ydb .AbstractCredentials | None = None ,
341
+ protocol : str | None = None ,
342
+ credentials : ydb .Credentials | None = None ,
337
343
ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
338
344
** kwargs : dict ,
339
345
) -> None :
@@ -342,6 +348,7 @@ def __init__(
342
348
port = port ,
343
349
database = database ,
344
350
ydb_table_path_prefix = ydb_table_path_prefix ,
351
+ protocol = protocol ,
345
352
credentials = credentials ,
346
353
ydb_session_pool = ydb_session_pool ,
347
354
** kwargs ,
0 commit comments