Create, drop, insert table in postgres
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE IF NOT EXISTS weather (
|
||||
dateTime TIMESTAMPTZ NOT NULL,
|
||||
city VARCHAR(255) NOT NULL,
|
||||
tempMax DOUBLE PRECISION,
|
||||
tempMin DOUBLE PRECISION,
|
||||
tempAvg DOUBLE PRECISION,
|
||||
precipitation DOUBLE PRECISION,
|
||||
windAvg DOUBLE PRECISION,
|
||||
windMax DOUBLE PRECISION,
|
||||
visibilityMin DOUBLE PRECISION,
|
||||
visibilityAvg DOUBLE PRECISION,
|
||||
snowAvg DOUBLE PRECISION,
|
||||
atmPressure DOUBLE PRECISION,
|
||||
dewPoint DOUBLE PRECISION,
|
||||
humidity DOUBLE PRECISION,
|
||||
sunDuration DOUBLE PRECISION,
|
||||
phenomena TEXT[],
|
||||
UNIQUE(city, dateTime)
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE weather
|
||||
@@ -0,0 +1,18 @@
|
||||
INSERT INTO weather (dateTime, city, tempMax, tempMin, tempAvg, precipitation, windAvg, windMax, visibilityMin, visibilityAvg, snowAvg, atmPressure, dewPoint, humidity, sunDuration, phenomena)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT (city, dateTime)
|
||||
DO UPDATE SET
|
||||
tempMax = excluded.tempMax,
|
||||
tempMin = excluded.tempMin,
|
||||
tempAvg = excluded.tempAvg,
|
||||
precipitation = excluded.precipitation,
|
||||
windAvg = excluded.windAvg,
|
||||
windMax = excluded.windMax,
|
||||
visibilityMin = excluded.visibilityMin,
|
||||
visibilityAvg = excluded.visibilityAvg,
|
||||
snowAvg = excluded.snowAvg,
|
||||
atmPressure = excluded.atmPressure,
|
||||
dewPoint = excluded.dewPoint,
|
||||
humidity = excluded.humidity,
|
||||
sunDuration = excluded.sunDuration,
|
||||
phenomena = excluded.phenomena;
|
||||
Reference in New Issue
Block a user