Reputation: 486
I'm importing a CSV file using the Google Cloud SQL API.
After the import, I want to check for errors to make sure the file was imported successfully.
I'm following the documentation here:
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/import
I'm monitoring the status of each import using the 'Operations' tab in the Google Cloud Console.
I've noticed that if I upload a CSV file with invalid data, the operations tab still shows that the operation succeeded.
Here is the error message I see when uploading the CSV file using PHPMyAdmin:
Cannot add or update a child row: a foreign key constraint fails (
my_schema
.table_two
, CONSTRAINTtable_two_ibfk_1
FOREIGN KEY (field_name
) REFERENCEStable_one
(field_name
) ON DELETE CASCADE ON UPDATE CASCADE)
But when I upload the same CSV file using the API, the operations tab shows that the import succeeded (screenshot below):
I've also tried fetching the operation details from the Google API to check for errors:
https://www.googleapis.com/sql/v1beta4/projects/{my-project}/operations/020352dd-70a4-4da2-****-******
I get the following response which shows no details of any errors:
{
"kind": "sql#operation",
...
"operationType": "IMPORT",
"status": "DONE",
...
"importContext": {
"kind": "sql#importContext",
"uri": "gs://****.csv",
...
"csvImportOptions": {
...
}
}
The CSV file I'm importing has around 10,000 rows. I understand the reason for the error when importing, but I'm trying to find a way to monitor imports to ensure no data is lost.
Is there any way to check that CSV imports complete successfully?
Thank you.
Upvotes: 1
Views: 654