Skip to content

Commit

Permalink
[PPANTT-51] feat: introduced python scripts to update data of iban an…
Browse files Browse the repository at this point in the history
…d iban master
  • Loading branch information
alessio-cialini committed Aug 26, 2024
1 parent b56c977 commit 1df1c86
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/utils/updateIbanFkPa/oracleUpdatesIbanFkPa.py
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()

17 changes: 17 additions & 0 deletions scripts/utils/updateIbanFkPa/postgresUpdateIbanFkPa.py
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()
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()

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()

0 comments on commit 1df1c86

Please sign in to comment.