File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import oracledb
2+ import config
3+ from time import sleep
4+
5+ def update_country_code (connection : oracledb .Connection , country_code : str = "US" ) -> None :
6+
7+ # First retrieve all rows that have "US" as country_code
8+ cursor = connection .cursor ()
9+ statement = """
10+ SELECT *
11+ FROM ADMIN.DEMOGRAPHICS demographics
12+ WHERE demographics.COUNTRY_CODE = :1
13+ """
14+ cursor .execute (statement , [country_code ])
15+ results = cursor .fetchall ()
16+
17+ # Update country_codes for all customers from US to USA
18+
19+ for result in results :
20+ statement = """
21+ UPDATE ADMIN.DEMOGRAPHICS demographics
22+ SET demographics.COUNTRY_CODE = 'USA'
23+ WHERE demographics.ID = :1
24+ """
25+ cursor .execute (statement , [result [0 ]])
26+ connection .commit ()
27+ print ("Updated country code for customer id: " + result [0 ])
28+ sleep (5 )
29+ cursor .close ()
30+
31+ if __name__ == "__main__" :
32+
33+ with oracledb .connect (
34+ user = config .username ,
35+ password = config .password ,
36+ dsn = config .dsn ,
37+ port = config .port ) as connection :
38+
39+ update_country_code (connection )
You can’t perform that action at this time.
0 commit comments