menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Cloud News

>

Connect to...
source image

Dev

2w

read

60

img
dot

Image Credit: Dev

Connect to Azure SQL database in SQL Alchemy using Entra ID tokens

  • To connect to an Azure SQL database using SQL Alchemy and pyodbc, the application requires a new session for each request to the database.
  • To achieve this, the requests can be wrapped into decorators that create and close a new session for each request.
  • SQL Alchemy provides a scoped session utility that ensures the reuse of existing session objects throughout the application, preventing race conditions.
  • To connect via Entra ID tokens using managed identity, event handlers can be added to retrieve and add the access token to the connection string.

Read Full Article

like

3 Likes

For uninterrupted reading, download the app