diff options
author | Patrick Simianer <pks@pks.rocks> | 2019-01-27 00:27:21 +0100 |
---|---|---|
committer | Patrick Simianer <pks@pks.rocks> | 2019-01-27 00:27:21 +0100 |
commit | 843bb50c48a8b11c572c1e64e0237d09d635e1f0 (patch) | |
tree | 60fe62048b80ef392b275e77df69748e41fd81df /create-db.rb |
init
Diffstat (limited to 'create-db.rb')
-rwxr-xr-x | create-db.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/create-db.rb b/create-db.rb new file mode 100755 index 0000000..12326c0 --- /dev/null +++ b/create-db.rb @@ -0,0 +1,50 @@ +#!/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 + ); + SQL + +db.close + |