Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading