From 796962e11718224e115def4e9938e952a2cb7871 Mon Sep 17 00:00:00 2001 From: Xinyi He Date: Sat, 7 Oct 2023 00:33:35 -0700 Subject: [PATCH] remove u --- python/ETL/transfer.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/python/ETL/transfer.py b/python/ETL/transfer.py index 097b2ce..ff3deb7 100644 --- a/python/ETL/transfer.py +++ b/python/ETL/transfer.py @@ -1,12 +1,10 @@ -#DATABASE_URL=postgresql://doadmin:l5al4hwte8qmj6x8@db-postgresql-sfo2-nextgen-do-user-1067699-0.db.ondigitalocean.com:25060/treetracker?ssl=true import psycopg2 -import argparse -import datetime -DATABASE_URL="postgresql://doadmin:l5al4hwte8qmj6x8@db-postgresql-sfo2-nextgen-do-user-1067699-0.db.ondigitalocean.com:25060/treetracker?ssl=true" -def transfer_data(target=None, source=DATABASE_URL, organization_name=None, organization_id = None, action = False): + + +def transfer_data(target, source, organization_id = None, action = False): """ Transfer organizations data and related planter, trees from source to target. @@ -24,7 +22,7 @@ def transfer_data(target=None, source=DATABASE_URL, organization_name=None, orga #connect source database src_conn = psycopg2.connect(source) src_cur = src_conn.cursor() - org_name = organization_name if organization_name else organization_id + org_name = organization_id @@ -148,13 +146,3 @@ def insert_or_update(table_name, columns, data, dest_cur, dest_conn, action=Fals return - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Transfer data from source to target database.") - parser.add_argument("-t","--target_db", default=None, help="URI for the target PostgreSQL database.") - parser.add_argument("-s","--source_db", default=DATABASE_URL, help="URI for the source PostgreSQL database.") - parser.add_argument("-o","--org_id", required=True, type=int, help="ID of the target organization.") - parser.add_argument("-a","--action", default = False,type=bool, help="Whether to update the database.") - args = parser.parse_args() - transfer_data(target=args.target_db, source=args.source_db,organization_id=args.org_id, action=args.action) \ No newline at end of file