2020from .errors import NotSupportedError
2121from .utils import handle_ydb_errors
2222from .utils import maybe_get_current_trace_id
23+ from .utils import prepare_credentials
2324
2425
2526class IsolationLevel (str , Enum ):
@@ -69,13 +70,15 @@ def __init__(
6970 port : str = "" ,
7071 database : str = "" ,
7172 ydb_table_path_prefix : str = "" ,
72- credentials : ydb .AbstractCredentials | None = None ,
73+ protocol : str | None = None ,
74+ credentials : ydb .Credentials | dict | str | None = None ,
7375 ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
7476 ** kwargs : dict ,
7577 ) -> 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 )
7781 self .database = database
78- self .credentials = credentials
7982 self .table_path_prefix = ydb_table_path_prefix
8083
8184 self .connection_kwargs : dict = kwargs
@@ -170,7 +173,8 @@ def __init__(
170173 port : str = "" ,
171174 database : str = "" ,
172175 ydb_table_path_prefix : str = "" ,
173- credentials : ydb .AbstractCredentials | None = None ,
176+ protocol : str | None = None ,
177+ credentials : ydb .Credentials | None = None ,
174178 ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
175179 ** kwargs : dict ,
176180 ) -> None :
@@ -179,6 +183,7 @@ def __init__(
179183 port = port ,
180184 database = database ,
181185 ydb_table_path_prefix = ydb_table_path_prefix ,
186+ protocol = protocol ,
182187 credentials = credentials ,
183188 ydb_session_pool = ydb_session_pool ,
184189 ** kwargs ,
@@ -333,7 +338,8 @@ def __init__(
333338 port : str = "" ,
334339 database : str = "" ,
335340 ydb_table_path_prefix : str = "" ,
336- credentials : ydb .AbstractCredentials | None = None ,
341+ protocol : str | None = None ,
342+ credentials : ydb .Credentials | None = None ,
337343 ydb_session_pool : SessionPool | AsyncSessionPool | None = None ,
338344 ** kwargs : dict ,
339345 ) -> None :
@@ -342,6 +348,7 @@ def __init__(
342348 port = port ,
343349 database = database ,
344350 ydb_table_path_prefix = ydb_table_path_prefix ,
351+ protocol = protocol ,
345352 credentials = credentials ,
346353 ydb_session_pool = ydb_session_pool ,
347354 ** kwargs ,
0 commit comments