I am trying to upload a csv file on mariadb using MySQLWorkbench but with no success, what is happening, I do have my table as:
CREATE TABLE `emissora` (
`id_emissora` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ds_nome` varchar(100) NOT NULL,
`id_tipo_emissora` tinyint(4) DEFAULT NULL,
`ds_modulacao` varchar(5) NOT NULL,
`ds_frequencia` varchar(10) NOT NULL,
`nr_alcance` int(3) DEFAULT NULL,
`perc_alcance` decimal(5,2) DEFAULT NULL,
`qt_habitantes_alcance` int(11) DEFAULT NULL,
`ds_url` varchar(100) DEFAULT NULL,
`ds_streaming` varchar(100) DEFAULT NULL,
`ds_id_anatel` varchar(100) DEFAULT NULL,
`id_uf` int(11) DEFAULT NULL,
`ds_uf` varchar(100) DEFAULT NULL,
`id_municipio` int(10) DEFAULT NULL,
`ds_municipio` varchar(100) DEFAULT NULL,
`id_regiao` int(11) DEFAULT NULL,
`id_genero_musical` int(11) DEFAULT NULL,
PRIMARY KEY (`id_emissora`)
) ENGINE=InnoDB AUTO_INCREMENT=11129 DEFAULT CHARSET=utf8;
but when I try to import the csv file example below:
id_emissora;ds_nome;id_tipo_emissora;ds_modulacao;ds_frequencia;nr_alcance;perc_alcance;qt_habitantes_alcance;ds_url;ds_streaming;ds_id_anatel;id_uf;ds_uf;id_municipio;ds_municipio;id_regiao;id_genero_musical
4;Cultura;;FM;102.5;0;;1;http://www.cultura.fm.br/;;;16;PR;2969;Cultura;5;
6;Abdallah;;FM;104.1;55;;1;http://www.abdallahfm.com.br/;http://server3.webradios.com.br:9338/9338;57dbac33ef411;16;PR;2911;Abdallah;5;Sertaneja
7;Aline;;FM;93.7;0;;1;http://www.alinefm.com.br;http://controleflash.omegasistemas.net:8356/;;;;;;;
8;Amiga;;FM;101.3;40;;1;http://www.amiga101.com.br;http://stream4.painelvox.com.br:7052;57dbac337965d;16;PR;2878;Amiga;5;Sertaneja
I am receiving the error below:
DBError: ('Cannot delete or update a parent row: a foreign key constraint fails', 1451)
ERROR: Import data file: ('Cannot delete or update a parent row: a foreign key constraint fails', 1451)
And when I try to import without drop table and create again, I am receiving the error below:
Prepare Import...
Prepare Import done
Import data file....
- Prepare Import
- Begin Import
- Row import failed with error: ("Incorrect integer value: '' for column 'id_genero_musical' at row 1", 1366)
- Row import failed with error: ("Incorrect integer value: 'Sertaneja' for column 'id_genero_musical' at row 1", 1366)
- Row import failed with error: ("Incorrect integer value: '' for column 'id_genero_musical' at row 1", 1366)
Your Table Schema is just fine. You have an error in the data import statement. In the data import statement the number of items in each row mismatch with the number of columns at the first row. Set empty semi-colons ; for null values and check if the number of semi-colons in each row is equal to the number of columns in the first row.