Project

General

Profile

« Previous | Next » 

Revision 37

xml2db: Improved empty_db to use TRUNCATE instead of DROP DATABASE. Added xml2vegbank to automatically set db env vars.

View differences:

scripts/xml2db/test
4 4
selfDir="$(dirname -- "$0")"
5 5
cd "$selfDir"
6 6

  
7
export host=localhost user=vegbank password=vegbank database=vegbank
8

  
9
./xml2db <vb_plot_observation.xml
7
./xml2vegbank <vb_plot_observation.xml
scripts/xml2db/xml2vegbank
1
#!/bin/bash
2
# Runs xml2db with output to vegbank
3

  
4
selfDir="$(dirname -- "$0")"
5

  
6
export host=localhost user=vegbank password=vegbank database=vegbank
7

  
8
"$selfDir/xml2db"
0 9

  
scripts/xml2db/empty_db
2 2
# Resets vegbank db
3 3

  
4 4
selfDir="$(dirname -- "$0")"
5
cd "$selfDir"
6 5

  
7
sudo -u postgres psql <vegbank.sql
6
export PGHOST=localhost PGUSER=vegbank PGPASSWORD=vegbank \
7
PGOPTIONS='--client-min-messages=WARNING'
8

  
9
psql --quiet --dbname=vegbank <"$selfDir/vegbank_reset.sql"
scripts/xml2db/vegbank.sql
1
DROP DATABASE IF EXISTS vegbank;
2 1
--
3 2
-- PostgreSQL database dump
4 3
--
......
11 10
SET escape_string_warning = off;
12 11

  
13 12
--
14
-- Name: vegbank; Type: DATABASE; Schema: -; Owner: vegbank
13
-- Name: vegbank; Type: DATABASE; Schema: -; Owner: postgres
15 14
--
16 15

  
17
CREATE DATABASE vegbank WITH TEMPLATE = template0 ENCODING = 'UTF8';
16
CREATE DATABASE vegbank WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
18 17

  
19 18

  
20
ALTER DATABASE vegbank OWNER TO vegbank;
19
ALTER DATABASE vegbank OWNER TO postgres;
21 20

  
22 21
\connect vegbank
23 22

  
......
7239 7238

  
7240 7239

  
7241 7240
--
7242
-- Name: public; Type: ACL; Schema: -; Owner: vegbank
7241
-- Name: public; Type: ACL; Schema: -; Owner: postgres
7243 7242
--
7244 7243

  
7245 7244
REVOKE ALL ON SCHEMA public FROM PUBLIC;
7246
REVOKE ALL ON SCHEMA public FROM vegbank;
7247
GRANT ALL ON SCHEMA public TO vegbank;
7245
REVOKE ALL ON SCHEMA public FROM postgres;
7246
GRANT ALL ON SCHEMA public TO postgres;
7248 7247
GRANT ALL ON SCHEMA public TO PUBLIC;
7249 7248

  
7250 7249

  
scripts/xml2db/vegbank_reset.sql
1
TRUNCATE address CASCADE;
2
TRUNCATE aux_role CASCADE;
3
TRUNCATE classcontributor CASCADE;
4
TRUNCATE commclass CASCADE;
5
TRUNCATE commconcept CASCADE;
6
TRUNCATE commcorrelation CASCADE;
7
TRUNCATE comminterpretation CASCADE;
8
TRUNCATE commlineage CASCADE;
9
TRUNCATE commname CASCADE;
10
TRUNCATE commstatus CASCADE;
11
TRUNCATE commusage CASCADE;
12
TRUNCATE coverindex CASCADE;
13
TRUNCATE covermethod CASCADE;
14
TRUNCATE dba_confidentialitystatus CASCADE;
15
TRUNCATE dba_cookie CASCADE;
16
TRUNCATE dba_cookielabels CASCADE;
17
TRUNCATE dba_datacache CASCADE;
18
TRUNCATE dba_datamodelversion CASCADE;
19
TRUNCATE dba_dbstatstime CASCADE;
20
TRUNCATE dba_fielddescription CASCADE;
21
TRUNCATE dba_fieldlist CASCADE;
22
TRUNCATE dba_onerow CASCADE;
23
TRUNCATE dba_preassignacccode CASCADE;
24
TRUNCATE dba_tabledescription CASCADE;
25
TRUNCATE dba_xmlcache CASCADE;
26
TRUNCATE definedvalue CASCADE;
27
TRUNCATE disturbanceobs CASCADE;
28
TRUNCATE embargo CASCADE;
29
TRUNCATE graphic CASCADE;
30
TRUNCATE keywords CASCADE;
31
TRUNCATE keywords_extra CASCADE;
32
TRUNCATE namedplace CASCADE;
33
TRUNCATE namedplacecorrelation CASCADE;
34
TRUNCATE note CASCADE;
35
TRUNCATE notelink CASCADE;
36
TRUNCATE observation CASCADE;
37
TRUNCATE observationcontributor CASCADE;
38
TRUNCATE observationsynonym CASCADE;
39
TRUNCATE party CASCADE;
40
TRUNCATE partymember CASCADE;
41
TRUNCATE place CASCADE;
42
TRUNCATE plantconcept CASCADE;
43
TRUNCATE plantcorrelation CASCADE;
44
TRUNCATE plantlineage CASCADE;
45
TRUNCATE plantname CASCADE;
46
TRUNCATE plantstatus CASCADE;
47
TRUNCATE plantusage CASCADE;
48
TRUNCATE plot CASCADE;
49
TRUNCATE project CASCADE;
50
TRUNCATE projectcontributor CASCADE;
51
TRUNCATE reference CASCADE;
52
TRUNCATE referencealtident CASCADE;
53
TRUNCATE referencecontributor CASCADE;
54
TRUNCATE referencejournal CASCADE;
55
TRUNCATE referenceparty CASCADE;
56
TRUNCATE revision CASCADE;
57
TRUNCATE soilobs CASCADE;
58
TRUNCATE soiltaxon CASCADE;
59
TRUNCATE stemcount CASCADE;
60
TRUNCATE stemlocation CASCADE;
61
TRUNCATE stratum CASCADE;
62
TRUNCATE stratummethod CASCADE;
63
TRUNCATE stratumtype CASCADE;
64
TRUNCATE taxonalt CASCADE;
65
TRUNCATE taxonimportance CASCADE;
66
TRUNCATE taxoninterpretation CASCADE;
67
TRUNCATE taxonobservation CASCADE;
68
TRUNCATE telephone CASCADE;
69
TRUNCATE temptbl_std_commnames CASCADE;
70
TRUNCATE temptbl_std_plantnames CASCADE;
71
TRUNCATE usercertification CASCADE;
72
TRUNCATE userdataset CASCADE;
73
TRUNCATE userdatasetitem CASCADE;
74
TRUNCATE userdefined CASCADE;
75
TRUNCATE usernotify CASCADE;
76
TRUNCATE userpermission CASCADE;
77
TRUNCATE userpreference CASCADE;
78
TRUNCATE userquery CASCADE;
79
TRUNCATE userrecordowner CASCADE;
80
TRUNCATE userregionalexp CASCADE;
81
TRUNCATE usr CASCADE;

Also available in: Unified diff