Skip to content

Commit 99553fa

Browse files
committed
Add StaticCredentials parser
1 parent 217ad43 commit 99553fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ydb_dbapi/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,23 @@ def prepare_credentials(
134134

135135
if isinstance(credentials, dict):
136136
credentials = credentials or {}
137+
138+
username = credentials.get("username")
139+
if username:
140+
password = credentials.get("password")
141+
return ydb.StaticCredentials.from_user_password(
142+
username,
143+
password,
144+
)
145+
137146
token = credentials.get("token")
138147
if token:
139148
return ydb.AccessTokenCredentials(token)
140149

141150
service_account_json = credentials.get("service_account_json")
142151
if service_account_json:
143152
return ydb.iam.ServiceAccountCredentials.from_content(
144-
json.dumps(service_account_json)
153+
json.dumps(service_account_json),
145154
)
146155

147156
return ydb.AnonymousCredentials()

0 commit comments

Comments
 (0)