Skip to content

Commit

Permalink
remove u
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinyi He authored and Xinyi He committed Oct 7, 2023
1 parent bffc140 commit ab32668
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions python/ETL/transfer.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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



Expand Down Expand Up @@ -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)

0 comments on commit ab32668

Please sign in to comment.