目前,我使用设备代码凭据来访问 Azure AD。
device_code_credential = DeviceCodeCredential(
azure_client_id,
tenant_id=azure_tenant_id,
authority=azure_authority_uri)
Run Code Online (Sandbox Code Playgroud)
但我仍然需要使用 Azure 帐户用户名/密码来连接到 Azure SQL 服务器
driver = 'ODBC Driver 17 for SQL Server'
db_connection_string = f'DRIVER={driver};SERVER={server};' \
f'DATABASE={database};UID={user_name};PWD={password};'\
f'Authentication=ActiveDirectoryPassword;'\
'Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;'
connector = pyodbc.connect(db_connection_string)
Run Code Online (Sandbox Code Playgroud)
linux/MacOS 下的 python 有什么方法可以允许我使用 device_code_credential 和 access_token 连接到 Azure SQL 服务器吗?
https://github.com/mkleehammer/pyodbc/issues/228
我只得到了这个链接,但似乎不起作用。
有人有完整的工作样本吗?