test2 / modules /db_connection.py
AIdeaText's picture
Create db_connection.py
74ac7c0 verified
raw
history blame
600 Bytes
# modules/db_connection.py
import pymssql
from azure.identity import DefaultAzureCredential
def get_db_connection():
server = 'aideatexdb.database.windows.net'
database = 'textdb'
username = 'manuel.var.ale_aideatext.ai#EXT#@manuelvaraleaideatext.onmicrosoft.com'
credential = DefaultAzureCredential()
token = credential.get_token("https://database.windows.net/.default")
conn = pymssql.connect(server=server,
database=database,
user=username,
password=token.token)
return conn