Skip to content

Commit 7407d0a

Browse files
committed
Add slash to DB name
1 parent e2d61f9 commit 7407d0a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ydb_dbapi/connections.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(
7878
protocol = protocol if protocol else "grpc"
7979
self.endpoint = f"{protocol}://{host}:{port}"
8080
self.credentials = prepare_credentials(credentials)
81-
self.database = database
81+
self.database = self._maybe_add_slash(database)
8282
self.table_path_prefix = ydb_table_path_prefix
8383

8484
self.connection_kwargs: dict = kwargs
@@ -161,6 +161,15 @@ def _get_client_settings(self) -> ydb.QueryClientSettings:
161161
.with_native_json_in_result_sets(False)
162162
)
163163

164+
def _maybe_add_slash(self, database: str) -> str:
165+
if not database:
166+
return database
167+
168+
if database.startswith("/"):
169+
return database
170+
171+
return f"/{database}"
172+
164173

165174
class Connection(BaseConnection):
166175
_driver_cls = ydb.Driver

0 commit comments

Comments
 (0)