view create_feeds_db.tcl @ 430:8efbb045d44d

weather: Implement searching for nearest of measurement stations based on given lat/long coordinates. The distance calculation is naive pythagoraean one, should be changed to "Great circle distance" https://en.wikipedia.org/wiki/Great-circle_distance. (C implementation already done, just needs TCL-ization.)
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 08 Jan 2017 05:08:38 +0200
parents 416642f28d1e
children 1255d524a919
line wrap: on
line source

#!/usr/bin/tclsh
# TCL script for creating (empty) Feeds SQLite3 database
#
# Written by Matti 'ccr' Hamalainen <ccr@tnsp.org>
# (C) Copyright 2013 Tecnic Software productions (TNSP)
#
package require sqlite3
source [file dirname [info script]]/utillib.tcl

### Check commandline arguments
if {$argc < 1} {
  puts "Creates tables for Feeds target SQLite3 file"
  puts "Usage: $argv0 <output_sqlite3_db_file> \[-drop\]"
  puts ""
  puts "-drop option will drop any existing Feeds tables."
  exit 0
}

set db_drop 0
set db_output [lindex $argv 0]
if {$argc >= 2 && [lindex $argv 1] == "-drop"} {
  set db_drop 1
}

### Open database
open_db $db_output

if {$db_drop} {
  puts "WARNING! Dropping old tables Feeds requested!"
  puts "All data in those tables will be permanently lost!"

  if {![confirm_yesno "Proceed"]} {
    puts "Aborting procedure."
    dbh close
    exit 0
  }

  drop_table_feeds
}

create_table_feeds

dbh close

puts "DONE."