Database Data to Download Variables

Tagged with: , , , ,

Gets data from a MySql database, splits the data into separate columns, then uses one column in a URL to download something – and uses other column to name the file thats downloaded

for i in $(mysql -u root Project_Madapp -sNe 'SELECT CONCAT(id,",",name) AS yo FROM City WHERE type="actual"'); do parts=(${i//,/ }); wget -O "${parts[1]}.csv" "http://localhost/student_allocation_csv.php?format=csv&city_id=${parts[0]}"; done

One Response to “Database Data to Download Variables

  • 1
    Binny V A
    January 27th, 2016 01:43

    for i in *; do mysql -u root -sNe “create database $(basename $i ‘.sql’)”; mysql -u root $(basename $i ‘.sql’) < $i; done

    This will create the database – and then import the necessary data into it.

Leave a Reply