upload_exact.py 641 B

1234567891011121314151617181920212223242526272829
  1. """
  2. Upload exact match clusters to SQL.
  3. """
  4. import os
  5. import psycopg2
  6. from typing import Any
  7. def main(args: Any):
  8. csv_path: str = os.path.realpath(args.processed_csv)
  9. conn = psycopg2.connect(database = 'tornado', user = 'postgres')
  10. cursor = conn.cursor()
  11. cursor.execute(
  12. f"COPY exact_match(address, transaction, block_number, block_ts, meta_data, cluster) FROM '{csv_path}' DELIMITER ',' CSV HEADER;"
  13. )
  14. conn.commit()
  15. if __name__ == "__main__":
  16. import argparse
  17. parser = argparse.ArgumentParser()
  18. parser.add_argument('processed_csv', type=str)
  19. args = parser.parse_args()
  20. main(args)