Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.92 KB

README.md

File metadata and controls

36 lines (28 loc) · 1.92 KB

Database Table Data Transfer

This script is designed to transfer data from a source PostgreSQL database to a target PostgreSQL database. The script exports data from the source table into a CSV file and then imports the data from the CSV file into the target table.

Configuration

The script requires the following configurations to be set:

  • src_dbname: The name of the source database.
  • src_username: The username to use for the source database connection.
  • src_password: The password to use for the source database connection.
  • src_host: The host of the source database.
  • src_port: The port number to use for the source database connection (default is 5432).
  • src_schema: The schema of the source table.
  • src_table: The name of the source table.
  • tgt_dbname: The name of the target database.
  • tgt_username: The username to use for the target database connection.
  • tgt_password: The password to use for the target database connection.
  • tgt_host: The host of the target database.
  • tgt_port: The port number to use for the target database connection (default is 5432).
  • tgt_schema: The schema of the target table.
  • tgt_table: The name of the target table.
  • csv_path: The path to the temporary CSV file used for data transfer.

Usage

  1. Set the configuration variables at the top of the script.
  2. Run the script using Python (e.g., python script.py).
  3. The script will export data from the source table into a CSV file and then import the data from the CSV file into the target table.

Note: This script assumes that the source and target tables have the same structure. If the tables have different structures, you may need to modify the script accordingly.

Also, please be aware that this script does not handle any errors that may occur during the data transfer process. You may want to add error handling mechanisms to make the script more robust.