-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PPANTT-51] feat: introduced python scripts to update data of iban an…
…d iban master
- Loading branch information
1 parent
b56c977
commit 1df1c86
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import oracledb | ||
|
||
connection = oracledb.connect( | ||
dsn=os.environ['SPRING_DATASOURCE_HOST'], | ||
port=os.environ['SPRING_DATASOURCE_PORT'], | ||
user=os.environ['SPRING_DATASOURCE_USERNAME'], | ||
password=os.environ['SPRING_DATASOURCE_PASSWORD'] | ||
) | ||
cursor = connection.cursor() | ||
|
||
cursor.execute("UPDATE iban SET fk_pa = t.ext_pa FROM (SELECT master.fk_pa as ext_pa, master.fk_iban, MIN(master.inserted_date) FROM iban ib JOIN iban_master master ON master.fk_iban = ib.obj_id GROUP BY master.fk_pa, master.fk_iban) t WHERE obj_id = t.fk_iban AND fk_pa IS NULL") | ||
connection.commit() | ||
|
||
cursor.close() | ||
connection.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import psycopg2 | ||
|
||
sql_statement = 'UPDATE iban SET fk_pa = t.ext_pa FROM (SELECT master.fk_pa as ext_pa, master.fk_iban, MIN(master.inserted_date) FROM iban ib JOIN iban_master master ON master.fk_iban = ib.obj_id GROUP BY master.fk_pa, master.fk_iban) t WHERE obj_id = t.fk_iban AND fk_pa IS NULL' | ||
connection = oracledb.connect( | ||
database=os.environ['SPRING_DATASOURCE_DB'] | ||
host=os.environ['SPRING_DATASOURCE_HOST'], | ||
port=os.environ['SPRING_DATASOURCE_PORT'], | ||
user=os.environ['SPRING_DATASOURCE_USERNAME'], | ||
password=os.environ['SPRING_DATASOURCE_PASSWORD'] | ||
) | ||
cursor = connection.cursor() | ||
cursor.execute(sql_statement) | ||
connection.commit() | ||
|
||
cursor.close() | ||
connection.close() |
17 changes: 17 additions & 0 deletions
17
scripts/utils/updateIbanMasterDueDate/oracleUpdatesIbanMasterDueDate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import oracledb | ||
|
||
connection = oracledb.connect( | ||
dsn=os.environ['SPRING_DATASOURCE_HOST'], | ||
port=os.environ['SPRING_DATASOURCE_PORT'], | ||
user=os.environ['SPRING_DATASOURCE_USERNAME'], | ||
password=os.environ['SPRING_DATASOURCE_PASSWORD'] | ||
) | ||
cursor = connection.cursor() | ||
|
||
cursor.execute("UPDATE iban_master SET due_date = t.due_date FROM (SELECT DISTINCT ib.obj_id, ib.due_date FROM iban ib JOIN iban_master master ON master.fk_iban = ib.obj_id WHERE master.due_date IS NULL) t WHERE fk_iban = t.obj_id") | ||
connection.commit() | ||
|
||
cursor.close() | ||
connection.close() | ||
|
17 changes: 17 additions & 0 deletions
17
scripts/utils/updateIbanMasterDueDate/postgresUpdateIbanMasterDueDate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import psycopg2 | ||
|
||
sql_statement = '"UPDATE iban_master SET due_date = t.due_date FROM (SELECT DISTINCT ib.obj_id, ib.due_date FROM iban ib JOIN iban_master master ON master.fk_iban = ib.obj_id WHERE master.due_date IS NULL) t WHERE fk_iban = t.obj_id"' | ||
connection = oracledb.connect( | ||
database=os.environ['SPRING_DATASOURCE_DB'] | ||
host=os.environ['SPRING_DATASOURCE_HOST'], | ||
port=os.environ['SPRING_DATASOURCE_PORT'], | ||
user=os.environ['SPRING_DATASOURCE_USERNAME'], | ||
password=os.environ['SPRING_DATASOURCE_PASSWORD'] | ||
) | ||
cursor = connection.cursor() | ||
cursor.execute(sql_statement) | ||
connection.commit() | ||
|
||
cursor.close() | ||
connection.close() |