Skip to content

Commit

Permalink
Add slash to DB name
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvoleg committed Dec 4, 2024
1 parent e2d61f9 commit 7407d0a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ydb_dbapi/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
protocol = protocol if protocol else "grpc"
self.endpoint = f"{protocol}://{host}:{port}"
self.credentials = prepare_credentials(credentials)
self.database = database
self.database = self._maybe_add_slash(database)
self.table_path_prefix = ydb_table_path_prefix

self.connection_kwargs: dict = kwargs
Expand Down Expand Up @@ -161,6 +161,15 @@ def _get_client_settings(self) -> ydb.QueryClientSettings:
.with_native_json_in_result_sets(False)
)

def _maybe_add_slash(self, database: str) -> str:
if not database:
return database

if database.startswith("/"):
return database

return f"/{database}"


class Connection(BaseConnection):
_driver_cls = ydb.Driver
Expand Down

0 comments on commit 7407d0a

Please sign in to comment.