Skip to content

Commit

Permalink
Merge pull request #154 from pagopa/PAGOPA-1955-afm-modifica-abi-inte…
Browse files Browse the repository at this point in the history
…sa-prod

Pagopa 1955 afm modifica abi intesa prod
  • Loading branch information
FedericoRuzzier authored Jan 13, 2025
2 parents 8d4f7fc + 8e21491 commit 9dcc9b2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/updateABI/listTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from azure.data.tables import TableClient
from azure.data.tables import UpdateMode
import os
import sys

connection_string = os.environ['CONNECTION_STRING']
table_name = os.environ['TABLE_NAME']
table_client = TableClient.from_connection_string(conn_str=connection_string, table_name=table_name)

abi = sys.argv[1]
my_filter = (f"ABI eq '{abi}'")
entities = table_client.query_entities(my_filter)
for entity in entities:
print(entity)
23 changes: 23 additions & 0 deletions scripts/updateABI/updateTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from azure.data.tables import TableClient
from azure.data.tables import UpdateMode
import os
import sys

connection_string = os.environ['CONNECTION_STRING']
table_name = os.environ['TABLE_NAME']
table_client = TableClient.from_connection_string(conn_str=connection_string, table_name=table_name)

old_abi = sys.argv[1]
new_abi = sys.argv[2]
filter_before_update = (f"ABI eq '{old_abi}'")
filter_after_update = (f"ABI eq '{new_abi}'")

entities = table_client.query_entities(filter_before_update)
for entity in entities:
print(entity)
entity["ABI"] = new_abi
table_client.update_entity(mode=UpdateMode.MERGE, entity=entity)

entitiesAfterChange = table_client.query_entities(filter_after_update)
for entityAfterChange in entitiesAfterChange:
print(entityAfterChange)

0 comments on commit 9dcc9b2

Please sign in to comment.