FOREIGN_KEY constraint error when attempting to ETL s3 data to rds in embulk

Asked 2 years ago, Updated 2 years ago, 436 views

When I try to ETL the data of s3 to rds in embulk, I get a FOREIGN_KEY constraint error.
Specifically, the error is as follows:

java.lang.RuntimeException: com.mysql.jdbc.exception.jdbc4.MySQLIntegrityConstraintViolationException:Cannot delete or update a parent row:a foreign key constraint failures 
(`outputdb`.`TABLE_HISTORY`, CONSTRAINT`fk_TABLE_HISTORY_TABLE_HISTORY1`FOREIGN KEY(`PRIMARY_ID`,`SECOND_PRIMARY_ID`) REFERENCES`TABLE)

Primary key is configured in two columns (complex principal key) as shown above.

Set set FOREIGN_KEY_CHECKS=0; on mysql side

Embulk out describes the configuration as follows:
before_load: 'set FOREIGN_KEY_CHECKS=0;'

java mysql amazon-s3 embulk

2022-09-30 22:00

1 Answers

Now Resolved:

Look for Foreign Key Errors and check Foreign Key with the following command

SHOW CREATE TABLE table name;

Removed the Foreign Key.

ALTER TABLE table name DROP FOREIGN KEY foreign key name;


2022-09-30 22:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.