Skip to content

Commit

Permalink
Set port correctly in mssql connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
steinitzu committed Nov 1, 2023
1 parent ec639dd commit 360f165
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions dlt/destinations/mssql/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def _get_odbc_driver(self) -> str:
def to_odbc_dsn(self) -> str:
params = {
"DRIVER": self.odbc_driver,
"SERVER": self.host,
"PORT": self.port,
"SERVER": f"{self.host},{self.port}",
"DATABASE": self.database,
"UID": self.username,
"PWD": self.password,
Expand Down
24 changes: 24 additions & 0 deletions tests/load/mssql/test_mssql_credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from dlt.common.configuration import resolve_configuration

from dlt.destinations.mssql.configuration import MsSqlCredentials



def test_to_odbc_dsn() -> None:
creds = resolve_configuration(
MsSqlCredentials("mssql://test_user:[email protected]:12345/test_db?FOO=a&BAR=b")
)

dsn = creds.to_odbc_dsn()

result = {k: v for k, v in (param.split('=') for param in dsn.split(";"))}

assert result == {
'DRIVER': 'ODBC Driver 18 for SQL Server',
'SERVER': 'sql.example.com,12345',
'DATABASE': 'test_db',
'UID': 'test_user',
'PWD': 'test_password',
'FOO': 'a',
'BAR': 'b'
}

0 comments on commit 360f165

Please sign in to comment.