annotate db/mkdb @ 4:f561c7f130a0

Make -n not do any DB stuff so we don't need to #if the MySQL stuff out.
author Daniel O'Connor <darius@dons.net.au>
date Thu, 11 Feb 2010 11:47:11 +1030
parents 9dab44dcb331
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 /*
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2 * Create MySQL databases
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 * $Id: mkdb,v 1.3 2009/12/20 00:44:15 grog Exp grog $
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 create database if not exists weather;
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
6 use weather;
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
7 create table if not exists observations
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
8 (station_id char (16),
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
9 date date,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
10 time time,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
11 inside_humidity smallint null, /* humidity in percent */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
12 inside_temp float null, /* inside temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13 inside_dewpoint float null, /* inside dewpoint temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 outside_temp float null, /* outside temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 outside_dewpoint float null, /* outside dewpoint temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 apparent_temp float null, /* apparent outside temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 delta_t float null, /* delta to wet bulb temperature */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 outside_humidity smallint null, /* humidity in percent */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 pressure_abs float null, /* absolute pressure, hPa */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 pressure_msl float null, /* sea-level relative pressure, hPa */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 pressure_qnh float null, /* qnh pressure, hPa */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 visibility float null,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 wind_direction float, /* wind direction, in 45° increments */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 wind_direction_text char (6) null, /* wind direction, text */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 wind_speed float null, /* wind speed in km/h */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 wind_gust float null, /* wind gust speed in km/h */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27 rain float null, /* rainfall in mm */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 events text null, /* Not sure what this is */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 conditions text null, /* Not sure what this is */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 clouds text null, /* but what? */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 primary key (date, time, station_id));
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 create table if not exists remote_observations like observations;
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 /* Time of last report for this station to this remote site */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 create table if not exists lastreport
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 (station_id char (16), /* which station? */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 report_id char (16), /* and which remote site? */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 date timestamp, /* last report */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 primary key (station_id, report_id)
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 );
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 /* Configuration */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 create table if not exists config
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 ( version int, /* format version number */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 latitude float, /* In ° */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 longitude float,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
47 elevation float, /* metres */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 pressure_error float, /* difference between actual and real pressure, hPa */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 poll_interval int, /* time, in seconds, between reading the device */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 station_id char (16), /* this is the one we use for the database */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 address text, /* Address to display on web pages */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 wunderground_station_id text,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 wunderground_passwd text,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 wunderground_report_interval int, /* how many seconds between reports to Wunderground */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 weatheforyou_station_id text,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 weatheforyou_passwd text,
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57 weatherforyou_report_interval int, /* how many seconds between reports to Weather for you */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
58 website_generation_interval int, /* how many seconds between generating PHP header file */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
59 db_host text, /* database on this host */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
60 db_user text, /* user ID on host */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
61 db_passwd text, /* and password */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 db text, /* database name */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 db_table text, /* table */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
64 sharefile text, /* shared segment file */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
65 php_header text, /* php header file with weather data */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
66 comparefile text, /* file to compare local weather stations */
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
67 primary key (station_id)
9dab44dcb331 Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
68 );