Project

General

Profile

« Previous | Next » 

Revision 9456

lib/sh/db.sh: mysql_import(): automatically ensure the table is empty (i.e. using truncate()), unless append=1 is specified. extra calls to truncate() now that this happens automatically have also been removed.

View differences:

inputs/GBIF/raw_occurrence_record/run
26 26
 PRIMARY KEY (`acronym`)
27 27
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='from IH.vegpath.org?&Index+Herbariorum'
28 28
EOF
29
	truncate|mysql_ANSI
30 29
	mysql_import <"$top_dir"/herbaria_filter.csv_
31 30
}
32 31

  
lib/sh/db.sh
89 89
	(echo "SET sql_mode = 'ANSI';"; cat)|mysql "$@"
90 90
}
91 91

  
92
mysql_import() # usage: table=... [cols=...] mysql_import <file
92
mysql_import() # usage: table=... [cols=...] [append=1] mysql_import <file
93
# without append=1, first ensures the table is empty
93 94
{
94 95
	echo_func
95 96
	mk_table_esc
......
98 99
OPTIONALLY ENCLOSED BY '\"'
99 100
}"
100 101
	
102
	if test ! "$append"; then truncate|mysql_ANSI; fi
101 103
	mysql_load_data_format="${mysql_load_data_format%
102 104
}"
103 105
	mysql_ANSI "$@" 10<&0 <<EOF

Also available in: Unified diff