File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -26,3 +26,35 @@ def database_connection_query(sql: str): # To use when "select a from b"
2626 for r in cursor .execute (sql ):
2727 print (r )
2828 return r
29+
30+ def populate_ui_approved_users_table (user : str ): # To add users to the UI_APPROVED_USERS table
31+ load_dotenv ()
32+ un = os .getenv ("un" )
33+ cs = os .getenv ("cs" )
34+ pw = os .getenv ("pw" )
35+
36+ try :
37+ print ("Attempting DB connection..." )
38+ conn = oracledb .connect (user = un , password = pw , dsn = cs )
39+ print (conn .version , "DB connection successful!" )
40+ try :
41+ print ("Attempting to write to the db..." )
42+ cursor = conn .cursor ()
43+ cursor .execute (f'INSERT INTO "UI_APPROVED_USERSf" (OE_USER_CODE) VALUES ({ user } )' )
44+ print (conn .version , "DB write successful!" )
45+ except Exception as connectionError :
46+ print (f"Failed to connect to the DB! with connection error { connectionError } " )
47+ finally :
48+ if conn is not None :
49+ conn .close ()
50+ except Exception as dbWriteError :
51+ print (f"Failed to write to the DB! with write error { dbWriteError } " )
52+
53+
54+
55+
56+
57+
58+
59+
60+
You can’t perform that action at this time.
0 commit comments