dlt-hub / dlt

data load tool (dlt) is an open source Python library that makes data loading easy 🛠️
https://dlthub.com/docs
Apache License 2.0
2.65k stars 176 forks source link

Support passwordless authentication to Azure hosted MsSQL #2059

Open jfgreen-liberis opened 3 days ago

jfgreen-liberis commented 3 days ago

Feature description

Allow MsSQL destination to support passwordless authentication via a token.

This token is typically obtained using azure.identity.DefaultAzureCredential() but it can also be obtained via other methods like OIDC.

Are you a dlt user?

Yes, I'm already a dlt user.

Use case

I'm looking to get DLT setup reading/writing to MsSQL running in Azure and am hoping to use a passwordless connection.

Proposed solution

Looking at the current implementation, this might be as simple as modifying MsSqlCredentials to accept either a username/password or a token. If present, this token would then be included in pyodbc.connect via the attrs_before argument. If this sounds like an OK approach I am happy to draft a PR.

I experimented with doing a slightly underhanded runtime patch of pyodbc.connect with the added token and this seemed to work OK with DLT loading a table quite happily.

Related issues

No response