# Connect to the source RDS instance
conn1 = psycopg2.connect(host="source-rds-instance.abc123.us-east-1.rds.amazonaws.com", port=5432, database="mydatabase", user="myuser", password="mypassword")
cur1 = conn1.cursor()
# Connect to the target RDS instance
conn2 = psycopg2.connect(host="target-rds-instance.abc123.us-east-1.rds.amazonaws.com", port=5432, database="mydatabase", user="myuser", password="mypassword")
cur2 = conn2.cursor()
# Select all rows from the source table
cur1.execute("SELECT * FROM mytable")
# Iterate over the rows and insert them into the target table
for row in cur1:
cur2.execute("INSERT INTO mytable VALUES (%s, %s, %s)", row)
# Commit the changes to the target RDS instance
conn2.commit()
# Close the cursors and connections
cur1.close()
conn1.close()
cur2.close()
conn2.close()