Project

General

Profile

1
#!/bin/bash -e
2
. "$(dirname "${BASH_SOURCE[0]}")"/../../lib/runscripts/util.run
3
.rel ../../lib/sh/db.sh
4

    
5
# exports each BIEN2 country's species list
6

    
7
if self_not_included; then
8

    
9
all() # runtime: 1 min ("0m56.053s")
10
{
11
	begin_target; deferred_check_target_exists
12
	
13
	if ! isset password; then
14
		local_export password; read -rsp 'Enter your MySQL password: ' password
15
	fi
16
	local_export database=bien_web table=country_species
17
	
18
	split $'\n' "$(query="SELECT DISTINCT country FROM $table" mysql_export|tail -n +2)"
19
	local countries=("${parts[@]}")
20
	
21
	local country; for country in "${countries[@]}"; do
22
		filter="country = '$country'" stdout="$top_dir/$country.tsv" to_file \
23
		mysql_export
24
	done
25
}
26

    
27
fi
    (1-1/1)