Changeset 3332


Ignore:
Timestamp:
Dec 5, 2013, 3:52:45 PM (6 years ago)
Author:
nosdeputes
Message:

dump also as csv

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/bin/createQEdump.php

    r3331 r3332  
    2828  `nom_circo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    2929  `num_circo` smallint(2) UNSIGNED DEFAULT NULL,
    30   `sites_web` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    3130  `debut_mandat` date DEFAULT NULL,
    3231  `fin_mandat` date DEFAULT NULL,
     
    6160) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;');
    6261
    63 $bdd->query('INSERT INTO `'.$DBTABLE.'` SELECT qe.id, pa.slug, pa.nom, pa.sexe, pa.nom_circo, pa.num_circo, pa.sites_web, pa.debut_mandat, pa.fin_mandat, pa.place_hemicycle, pa.url_an, pa.profession, pa.groupe_acronyme,  qe.source, qe.legislature, qe.numero, qe.date, qe.date_cloture, qe.ministere, qe.themes, qe.question, qe.reponse, qe.motif_retrait
     62$bdd->query('INSERT INTO `'.$DBTABLE.'` SELECT qe.id, pa.slug, pa.nom, pa.sexe, pa.nom_circo, pa.num_circo, pa.debut_mandat, pa.fin_mandat, pa.place_hemicycle, pa.url_an, pa.profession, pa.groupe_acronyme,  qe.source, qe.legislature, qe.numero, qe.date, qe.date_cloture, qe.ministere, qe.themes, qe.question, qe.reponse, qe.motif_retrait
    6463FROM `question_ecrite` qe
    6564LEFT JOIN `parlementaire` pa
    6665ON qe.parlementaire_id = pa.id;');
    6766
    68 exec('mysqldump '.$var['MYSQLID'].' '.$DBNAME.' '.$DBTABLE.' | gzip -v > '.$DEST.$DBTABLE.'.sql.gz');
     67exec('mysqldump '.$var['MYSQLID'].' '.$DBNAME.' '.$DBTABLE.' | gzip -v > '.$DEST.'/nosdeputes.fr/'.$DBTABLE.'.sql.gz');
     68exec('mkdir -p /tmp/'.$DBTABLE);
     69exec('mysqldump '.$var['MYSQLID'].' '.$DBNAME.' '.$DBTABLE.' --tab=/tmp/'.$DBTABLE.' --fields-terminated-by="," --fields-enclosed-by="\""');
     70exec('echo "id,depute_slug,depute_nom,depute_sexe,depute_nom_circo,depute_num_circo,depute_debut_mandat,depute_fin_mandat,depute_place_hemicycle,depute_url_an,depute_profession,depute_groupe_acronyme,source,legislature,numero,date,date_cloture,ministere,themes,question,reponse,motif_retrait" > /tmp/'.$DBTABLE.'/'.$DBTABLE.'.csv');
     71exec("sed 's/\\\N//g' /tmp/".$DBTABLE.'/'.$DBTABLE.'.txt >> /tmp/'.$DBTABLE.'/'.$DBTABLE.'.csv');
     72exec('gzip -fv /tmp/'.$DBTABLE.'/'.$DBTABLE.'.csv');
     73exec('mv /tmp/'.$DBTABLE.'/'.$DBTABLE.'.csv.gz '.$DEST.'/nosdeputes.fr/');
    6974
    7075$bdd->query('DROP TABLE IF EXISTS `'.$DBTABLE.'`;');
Note: See TracChangeset for help on using the changeset viewer.