Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 12 additions & 3 deletions ibis-server/app/model/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ def get_clickhouse_connection(info: ClickHouseConnectionInfo) -> BaseBackend:
password=info.password.get_secret_value(),
)

@staticmethod
def get_mssql_connection(info: MSSqlConnectionInfo) -> BaseBackend:
@classmethod
def get_mssql_connection(cls, info: MSSqlConnectionInfo) -> BaseBackend:
return ibis.mssql.connect(
host=info.host.get_secret_value(),
port=info.port.get_secret_value(),
database=info.database.get_secret_value(),
user=info.user.get_secret_value(),
password=info.password.get_secret_value(),
password=cls._escape_special_characters_for_odbc(
info.password.get_secret_value()
),
driver=info.driver,
TDS_Version=info.tds_version,
**info.kwargs if info.kwargs else dict(),
Expand Down Expand Up @@ -161,3 +163,10 @@ def get_trino_connection(info: TrinoConnectionInfo) -> BaseBackend:
user=(info.user and info.user.get_secret_value()),
password=(info.password and info.password.get_secret_value()),
)

@staticmethod
def _escape_special_characters_for_odbc(value: str) -> str:
if ";" in value or value.startswith("{"):
return "{" + value.replace("}", "}}") + "}"
else:
return value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we always add brackets? Maybe we don't need to check if it contains any illegal character? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be okay.

4 changes: 3 additions & 1 deletion ibis-server/tests/routers/v2/connector/test_mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def manifest_str():
@pytest.fixture(scope="module")
def mssql(request) -> SqlServerContainer:
mssql = SqlServerContainer(
"mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04", dialect="mssql+pyodbc"
"mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04",
dialect="mssql+pyodbc",
password="{R;3G1/8Al2AniRye",
).start()
engine = sqlalchemy.create_engine(
f"{mssql.get_connection_url()}?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=YES"
Expand Down