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 89bba30 commit ff500cd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ydb_sqlalchemy/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ def reset_ydb_request_settings(self, dbapi_connection: ydb_dbapi.Connection):
def get_ydb_request_settings(self, dbapi_connection: ydb_dbapi.Connection) -> ydb.BaseRequestSettings:
return dbapi_connection.get_ydb_request_settings()

def create_connect_args(self, url):
args, kwargs = super().create_connect_args(url)
# YDB database name should start with '/'
if "database" in kwargs:
if not kwargs["database"].startswith("/"):
kwargs["database"] = "/" + kwargs["database"]

return [args, kwargs]

def connect(self, *cargs, **cparams):
return self.dbapi.connect(*cargs, **cparams)

Expand Down

0 comments on commit ff500cd

Please sign in to comment.