AIdeaText commited on
Commit
28aefca
1 Parent(s): 4d5950d

Update modules/db_connection.py

Browse files
Files changed (1) hide show
  1. modules/db_connection.py +10 -7
modules/db_connection.py CHANGED
@@ -1,17 +1,20 @@
1
- # modules/db_connection.py
 
 
2
  import pymssql
3
- from azure.identity import DefaultAzureCredential
4
 
5
  def get_db_connection():
6
  server = 'aideatexdb.database.windows.net'
7
  database = 'textdb'
8
- username = 'manuel.var.ale_aideatext.ai#EXT#@manuelvaraleaideatext.onmicrosoft.com'
9
-
10
- credential = DefaultAzureCredential()
 
 
11
  token = credential.get_token("https://database.windows.net/.default")
12
-
13
  conn = pymssql.connect(server=server,
14
  database=database,
15
- user=username,
16
  password=token.token)
17
  return conn
 
1
+ #db_connection.py
2
+ import os
3
+ from azure.identity import ClientSecretCredential
4
  import pymssql
 
5
 
6
  def get_db_connection():
7
  server = 'aideatexdb.database.windows.net'
8
  database = 'textdb'
9
+ client_id = os.getenv('AZURE_CLIENT_ID')
10
+ client_secret = os.getenv('AZURE_CLIENT_SECRET')
11
+ tenant_id = os.getenv('AZURE_TENANT_ID')
12
+
13
+ credential = ClientSecretCredential(tenant_id, client_id, client_secret)
14
  token = credential.get_token("https://database.windows.net/.default")
15
+
16
  conn = pymssql.connect(server=server,
17
  database=database,
18
+ user=client_id+'@'+server,
19
  password=token.token)
20
  return conn