Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect Azure Synapse severless DB using service principal and federated credential #1390

Open
kachely26 opened this issue Dec 4, 2024 · 0 comments

Comments

@kachely26
Copy link

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:

  • Python: 3.10.4
  • pyodbc: 5.2.0
  • OS: ubuntu22.04
  • DB: Azure Synapse serverless database
  • driver: {ODBC Driver 18 for SQL Server}

Issue

Hi pyodbc expert,

previously I used the code below as your suggestion to connect Azure SQL Server DB successfully.

def bytes2mswin_bstr(value: bytes) -> bytes:
    encoded_bytes = bytes(chain.from_iterable(zip(value, repeat(0))))    
    return struct.pack("<i", len(encoded_bytes)) + encoded_bytes

tokenstruct = bytes2mswin_bstr(token.encode())

conn = pyodbc.connect(connstr, attrs_before = {1256:tokenstruct}, timeout=30)

However, I could not use the same code to connect Azure Synapse Database.
What is the recommended way to connect Azure Synapse Database using non secret method?

Often it is easiest to describe your issue as "expected behavior" and "observed behavior".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant