summaryrefslogtreecommitdiff
path: root/v1/create-db.rb
blob: 2866b7b3b266c975fbbb54877e663863bff9fb71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env ruby

require 'sqlite3'

db = SQLite3::Database.new("weather.db")

db.execute <<-SQL
          create table rain(
           id INTEGER PRIMARY KEY,
           timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
           device_type TEXT,
           device_id TEXT,
           battery INTEGER,
           rssi INTEGER,
           rain_rate FLOAT,
           rain_total FLOAT
         );
        SQL
db.execute <<-SQL
          create table wind(
           id INTEGER PRIMARY KEY,
           timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
           device_type TEXT,
           device_id TEXT,
           battery INTEGER,
           rssi INTEGER,
           chill FLOAT,
           temperature FLOAT,
           average_speed FLOAT,
           direction INTEGER,
           gust FLOAT
         );
        SQL
db.execute <<-SQL
          create table temp(
           id INTEGER PRIMARY KEY,
           timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
           device_type TEXT,
           device_id TEXT,
           battery INTEGER,
           rssi INTEGER,
           humidity FLOAT,
           humidity_status TEXT,
           humidity_status_numeric INTEGER,
           temperature FLOAT,
           forecast TEXT,
           forecast_numeric INTEGER
         );
        SQL

db.close