Compare commits
7 Commits
4499313baa
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8aa528ff5b | |||
| 9754ffabaa | |||
| 9c2855fa98 | |||
| 4f89db49b6 | |||
| dfdd4943e1 | |||
| 4abaf5ee17 | |||
| 779a76dd92 |
@@ -289,6 +289,7 @@ Die aggregierten Endpunkte sind optimiert für Langzeit-Visualisierungen und red
|
||||
---
|
||||
|
||||
#### `GET /weather/rain-weekly`
|
||||
|
||||
**Gibt wöchentliche Regensummen zurück (Woche = Mo-So)**
|
||||
|
||||
**Query Parameter:**
|
||||
|
||||
+35
-21
@@ -270,11 +270,17 @@ async def get_weather_statistics(
|
||||
AVG(pressure) as avg_pressure,
|
||||
AVG(wind_speed * 1.60934) as avg_wind_speed,
|
||||
MAX(wind_gust * 1.60934) as max_wind_gust,
|
||||
SUM(rain) as total_rain,
|
||||
(SELECT COALESCE(SUM(daily_max), 0)
|
||||
FROM (
|
||||
SELECT MAX(rain) as daily_max
|
||||
FROM weather_data d2
|
||||
WHERE d2.datetime >= NOW() - make_interval(hours => %s)
|
||||
GROUP BY DATE(d2.datetime)
|
||||
) sub) as total_rain,
|
||||
COUNT(*) as data_points
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(hours => %s)
|
||||
""", (hours,))
|
||||
""", (hours, hours))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if not result or result['data_points'] == 0:
|
||||
@@ -300,7 +306,7 @@ async def get_daily_statistics(
|
||||
AVG(pressure) as avg_pressure,
|
||||
AVG(wind_speed * 1.60934) as avg_wind_speed,
|
||||
MAX(wind_gust * 1.60934) as max_wind_gust,
|
||||
SUM(rain) as total_rain,
|
||||
MAX(rain) as total_rain,
|
||||
COUNT(*) as data_points
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
@@ -387,7 +393,7 @@ async def get_hourly_aggregated_data(
|
||||
AVG(wind_speed * 1.60934) as wind_speed,
|
||||
MAX(wind_gust * 1.60934) as wind_gust,
|
||||
AVG(wind_dir) as wind_dir,
|
||||
AVG(rain) as rain,
|
||||
MAX(rain) as rain,
|
||||
AVG(rain_rate) as rain_rate,
|
||||
MAX(received_at) as received_at
|
||||
FROM weather_data
|
||||
@@ -429,14 +435,14 @@ async def get_daily_aggregated_data(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
SUM(rain)::float as total_rain
|
||||
MAX(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
ORDER BY datetime ASC
|
||||
""", (days,))
|
||||
results = cursor.fetchall()
|
||||
|
||||
|
||||
return [dict(row) for row in results]
|
||||
|
||||
|
||||
@@ -469,7 +475,7 @@ async def get_daily_with_minmax_data(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
SUM(rain)::float as total_rain
|
||||
MAX(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
@@ -488,9 +494,9 @@ async def get_daily_rain_data(
|
||||
"""Gibt tägliche Regensummen zurück"""
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
SELECT
|
||||
date_trunc('day', datetime) as date,
|
||||
SUM(rain) as total_rain
|
||||
MAX(rain) as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
@@ -511,21 +517,29 @@ async def get_weekly_rain_data(
|
||||
# Bei 365 Tagen: alle verfügbaren Daten zurückgeben
|
||||
if days >= 365:
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
date_trunc('week', datetime) as week_start,
|
||||
SUM(rain) as total_rain
|
||||
FROM weather_data
|
||||
GROUP BY date_trunc('week', datetime)
|
||||
SELECT
|
||||
date_trunc('week', day) as week_start,
|
||||
SUM(daily_rain) as total_rain
|
||||
FROM (
|
||||
SELECT DATE(datetime) as day, MAX(rain) as daily_rain
|
||||
FROM weather_data
|
||||
GROUP BY DATE(datetime)
|
||||
) sub
|
||||
GROUP BY date_trunc('week', day)
|
||||
ORDER BY week_start ASC
|
||||
""")
|
||||
else:
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
date_trunc('week', datetime) as week_start,
|
||||
SUM(rain) as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY date_trunc('week', datetime)
|
||||
SELECT
|
||||
date_trunc('week', day) as week_start,
|
||||
SUM(daily_rain) as total_rain
|
||||
FROM (
|
||||
SELECT DATE(datetime) as day, MAX(rain) as daily_rain
|
||||
FROM weather_data
|
||||
WHERE datetime >= NOW() - make_interval(days => %s)
|
||||
GROUP BY DATE(datetime)
|
||||
) sub
|
||||
GROUP BY date_trunc('week', day)
|
||||
ORDER BY week_start ASC
|
||||
""", (days,))
|
||||
results = cursor.fetchall()
|
||||
@@ -596,7 +610,7 @@ async def get_daily_aggregated_range(
|
||||
MAX(wind_gust * 1.60934)::float as wind_gust,
|
||||
(array_agg(datetime ORDER BY wind_gust DESC NULLS LAST))[1] as max_wind_gust_time,
|
||||
AVG(wind_dir)::float as wind_dir,
|
||||
SUM(rain)::float as total_rain
|
||||
MAX(rain)::float as total_rain
|
||||
FROM weather_data
|
||||
WHERE datetime BETWEEN %s AND %s
|
||||
GROUP BY date_trunc('day', datetime)
|
||||
|
||||
+18
-3
@@ -164,6 +164,9 @@ class WeatherDataInput(BaseModel):
|
||||
# Vorhersage
|
||||
forecast: Optional[int] = None
|
||||
|
||||
# Datenquelle
|
||||
source: Optional[str] = None
|
||||
|
||||
# ---- Validatoren -----------------------------------------------------
|
||||
|
||||
@field_validator("tempOut", "temperature", "tempIn")
|
||||
@@ -229,6 +232,13 @@ class WeatherDataInput(BaseModel):
|
||||
raise ValueError("rain value out of plausible range")
|
||||
return v
|
||||
|
||||
@field_validator("source")
|
||||
@classmethod
|
||||
def _source_valid(cls, v: Optional[str]) -> Optional[str]:
|
||||
if v is not None and v not in ("loop", "archive"):
|
||||
raise ValueError("source must be 'loop' or 'archive'")
|
||||
return v
|
||||
|
||||
# ---- Konvertierungen -------------------------------------------------
|
||||
|
||||
def get_datetime_string(self) -> str:
|
||||
@@ -330,6 +340,9 @@ def setup_database() -> None:
|
||||
cursor.execute(
|
||||
"ALTER TABLE weather_data ADD COLUMN IF NOT EXISTS bar_trend INTEGER"
|
||||
)
|
||||
cursor.execute(
|
||||
"ALTER TABLE weather_data ADD COLUMN IF NOT EXISTS source VARCHAR"
|
||||
)
|
||||
cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_weather_datetime_desc "
|
||||
"ON weather_data (datetime DESC)"
|
||||
@@ -500,6 +513,7 @@ def _store_weather(data: WeatherDataInput) -> dict:
|
||||
data.rain,
|
||||
data.get_rain_rate(),
|
||||
data.forecast,
|
||||
data.source,
|
||||
)
|
||||
|
||||
with pool.connection() as conn:
|
||||
@@ -509,8 +523,8 @@ def _store_weather(data: WeatherDataInput) -> dict:
|
||||
INSERT INTO weather_data
|
||||
(datetime, temperature, temp_in, humidity, humidity_in,
|
||||
pressure, bar_trend, wind_speed, wind_gust, wind_dir,
|
||||
rain, rain_rate, forecast)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
rain, rain_rate, forecast, source)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
ON CONFLICT (datetime) DO UPDATE SET
|
||||
temperature = EXCLUDED.temperature,
|
||||
temp_in = EXCLUDED.temp_in,
|
||||
@@ -523,7 +537,8 @@ def _store_weather(data: WeatherDataInput) -> dict:
|
||||
wind_dir = EXCLUDED.wind_dir,
|
||||
rain = EXCLUDED.rain,
|
||||
rain_rate = EXCLUDED.rain_rate,
|
||||
forecast = EXCLUDED.forecast
|
||||
forecast = EXCLUDED.forecast,
|
||||
source = EXCLUDED.source
|
||||
""",
|
||||
values,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deploy Script für laufschrift
|
||||
# Deploy Script für wetterstation
|
||||
# Baut das Docker Image und lädt es zu docker.citysensor.de hoch
|
||||
|
||||
set -e
|
||||
|
||||
@@ -92,6 +92,23 @@ services:
|
||||
- "traefik.http.routers.wetterstation.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.wetterstation.loadbalancer.server.port=80"
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4:latest
|
||||
container_name: wetterstation_pgadmin_prod
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
|
||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
|
||||
PGADMIN_CONFIG_SERVER_MODE: 'True'
|
||||
volumes:
|
||||
- pgadmin_data:/var/lib/pgadmin
|
||||
depends_on:
|
||||
- postgres
|
||||
networks:
|
||||
- internal
|
||||
labels:
|
||||
- "traefik.enable=false"
|
||||
|
||||
monitor:
|
||||
image: docker.citysensor.de/wetterstation-monitor:latest
|
||||
container_name: wetterstation_monitor_prod
|
||||
@@ -102,6 +119,8 @@ services:
|
||||
volumes:
|
||||
postgres_data:
|
||||
name: wetterstation_postgres_data_prod
|
||||
pgadmin_data:
|
||||
name: wetterstation_pgadmin_data_prod
|
||||
|
||||
networks:
|
||||
internal:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wetterstation-frontend",
|
||||
"private": true,
|
||||
"version": "1.5.6",
|
||||
"version": "1.6.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -26,8 +26,8 @@ function buildUrls(timeRange) {
|
||||
const days = timeRange.days || 1
|
||||
const path = days >= 7 ? 'daily-aggregated-range' : 'hourly-aggregated-range'
|
||||
return {
|
||||
weatherUrl: `${API_BASE}/weather/${path}?start=${start}&end=${end}`,
|
||||
rainUrl: null, // TODO: Regen-Aggregation fuer Range implementieren
|
||||
weatherUrl: `${API_BASE}/weather/${path}?start=${start}&end=${end}`,
|
||||
rainUrl: days < 7 ? `${API_BASE}/weather/daily-aggregated-range?start=${start}&end=${end}` : null,
|
||||
needsCurrent: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,14 +171,14 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
|
||||
// Spezieller Suffix für Regen
|
||||
const rainSuffix = useMemo(() => {
|
||||
if (typeof timeRange === 'object' && timeRange.type === 'custom') {
|
||||
const days = timeRange.days || 1
|
||||
return days >= 7 ? ' (pro Tag)' : ''
|
||||
return ' (pro Tag)'
|
||||
}
|
||||
switch (timeRange) {
|
||||
case '7d':
|
||||
case '30d':
|
||||
case '365d':
|
||||
return ' (pro Tag)'
|
||||
case '365d':
|
||||
return ' (pro Woche)'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
@@ -291,30 +291,93 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
|
||||
}
|
||||
} else {
|
||||
// Vordefinierte Bereiche
|
||||
const pad = n => String(n).padStart(2, '0')
|
||||
const fmtDate = d => `${pad(d.getDate())}.${pad(d.getMonth() + 1)}`
|
||||
const fmtTime = d => `${pad(d.getHours())}:${pad(d.getMinutes())}`
|
||||
|
||||
switch (timeRange) {
|
||||
case '24h':
|
||||
xAxisConfig.tickInterval = 4 * 3600 * 1000 // 4 Stunden
|
||||
xAxisConfig.labels = { format: '{value:%H:%M}', align: 'center' }
|
||||
xAxisConfig.tickPositioner = function() {
|
||||
const positions = []
|
||||
const d = new Date(this.min)
|
||||
d.setMinutes(0, 0, 0)
|
||||
const h = d.getHours()
|
||||
const nextH = Math.ceil(h / 4) * 4
|
||||
if (nextH >= 24) { d.setDate(d.getDate() + 1); d.setHours(0, 0, 0, 0) }
|
||||
else d.setHours(nextH, 0, 0, 0)
|
||||
while (d.getTime() <= this.max) {
|
||||
positions.push(d.getTime())
|
||||
d.setHours(d.getHours() + 4, 0, 0, 0)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
xAxisConfig.labels = {
|
||||
rotation: 0, align: 'center', useHTML: true,
|
||||
formatter: function() {
|
||||
const d = new Date(this.value)
|
||||
return d.getHours() === 0 && d.getMinutes() === 0
|
||||
? `<span style="color:#3b82f6;font-weight:bold">${fmtDate(d)}</span>`
|
||||
: fmtTime(d)
|
||||
}
|
||||
}
|
||||
xAxisMin = now - 24 * 3600 * 1000
|
||||
xAxisMax = now
|
||||
tooltipDateFormat = '%d.%m.%Y %H:%M'
|
||||
break
|
||||
case '7d':
|
||||
xAxisConfig.labels = { format: '{value:%d.%m}', align: 'center' }
|
||||
xAxisConfig.tickPositioner = function() {
|
||||
const positions = []
|
||||
const d = new Date(this.min)
|
||||
d.setHours(0, 0, 0, 0)
|
||||
while (d.getTime() <= this.max) {
|
||||
positions.push(d.getTime())
|
||||
d.setDate(d.getDate() + 1)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
xAxisConfig.labels = {
|
||||
rotation: 0, align: 'center',
|
||||
formatter: function() { return fmtDate(new Date(this.value)) }
|
||||
}
|
||||
xAxisMin = now - 7 * 24 * 3600 * 1000
|
||||
xAxisMax = now
|
||||
tooltipDateFormat = '%d.%m.%Y'
|
||||
break
|
||||
case '30d':
|
||||
xAxisConfig.labels = { format: '{value:%d.%m}', align: 'center' }
|
||||
xAxisConfig.tickPositioner = function() {
|
||||
const positions = []
|
||||
const d = new Date(this.min)
|
||||
d.setHours(0, 0, 0, 0)
|
||||
while (d.getTime() <= this.max) {
|
||||
positions.push(d.getTime())
|
||||
d.setDate(d.getDate() + 5)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
xAxisConfig.labels = {
|
||||
rotation: 0, align: 'center',
|
||||
formatter: function() { return fmtDate(new Date(this.value)) }
|
||||
}
|
||||
xAxisMin = now - 30 * 24 * 3600 * 1000
|
||||
xAxisMax = now
|
||||
tooltipDateFormat = '%d.%m.%Y'
|
||||
break
|
||||
case '365d':
|
||||
xAxisConfig.labels = { format: '{value:%b %Y}', align: 'center' }
|
||||
tooltipDateFormat = '%b %Y'
|
||||
// Bei 365d: Min/Max aus vorhandenen Daten berechnen
|
||||
xAxisConfig.tickPositioner = function() {
|
||||
const positions = []
|
||||
const d = new Date(this.min)
|
||||
d.setDate(1); d.setHours(0, 0, 0, 0)
|
||||
while (d.getTime() <= this.max) {
|
||||
positions.push(d.getTime())
|
||||
d.setMonth(d.getMonth() + 1)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
xAxisConfig.labels = {
|
||||
rotation: 0, align: 'center',
|
||||
formatter: function() { return pad(new Date(this.value).getMonth() + 1) }
|
||||
}
|
||||
tooltipDateFormat = '%d.%m.%Y'
|
||||
if (sortedData.length > 0) {
|
||||
xAxisMin = new Date(sortedData[0].datetime).getTime()
|
||||
xAxisMax = new Date(sortedData[sortedData.length - 1].datetime).getTime()
|
||||
@@ -324,8 +387,27 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
|
||||
}
|
||||
break
|
||||
default:
|
||||
xAxisConfig.tickInterval = 4 * 3600 * 1000
|
||||
xAxisConfig.labels = { format: '{value:%H:%M}', align: 'center' }
|
||||
xAxisConfig.tickPositioner = function() {
|
||||
const positions = []
|
||||
const d = new Date(this.min)
|
||||
d.setMinutes(0, 0, 0)
|
||||
const h = d.getHours()
|
||||
const nextH = Math.ceil(h / 4) * 4
|
||||
if (nextH >= 24) { d.setDate(d.getDate() + 1); d.setHours(0, 0, 0, 0) }
|
||||
else d.setHours(nextH, 0, 0, 0)
|
||||
while (d.getTime() <= this.max) {
|
||||
positions.push(d.getTime())
|
||||
d.setHours(d.getHours() + 4, 0, 0, 0)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
xAxisConfig.labels = {
|
||||
rotation: 0, align: 'center',
|
||||
formatter: function() {
|
||||
const d = new Date(this.value)
|
||||
return d.getHours() === 0 && d.getMinutes() === 0 ? fmtDate(d) : fmtTime(d)
|
||||
}
|
||||
}
|
||||
xAxisMin = now - 24 * 3600 * 1000
|
||||
xAxisMax = now
|
||||
tooltipDateFormat = '%d.%m.%Y %H:%M'
|
||||
@@ -639,11 +721,13 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
|
||||
}
|
||||
}]
|
||||
} else if (typeof timeRange === 'object' && timeRange.type === 'custom') {
|
||||
// Custom range: tägliche Summen aus sortedData (total_rain ist im daily-aggregated-range enthalten)
|
||||
// Custom range: tägliche Summen — bei kurzen Ranges (<7d) aus rainData (extra Fetch),
|
||||
// bei langen Ranges aus sortedData (daily-aggregated-range enthält total_rain)
|
||||
yAxisTitle = 'Regen (mm pro Tag)'
|
||||
const rainSource = rainData.length > 0 ? rainData : sortedData
|
||||
series = [{
|
||||
name: 'Regen',
|
||||
data: sortedData
|
||||
data: rainSource
|
||||
.filter(item => item.total_rain != null && item.total_rain > 0)
|
||||
.map(item => [new Date(item.datetime).getTime(), item.total_rain]),
|
||||
color: 'rgb(54, 162, 235)',
|
||||
|
||||
@@ -19,7 +19,7 @@ load_dotenv(dotenv_path=env_path)
|
||||
# Konfiguration
|
||||
SQLITE_DB = "data/wview-archive.sdb"
|
||||
START_DATE = datetime(2025, 1, 1, 0, 0, 0, tzinfo=timezone.utc)
|
||||
END_DATE = datetime(2026, 2, 8, 0, 0, 0, tzinfo=timezone.utc)
|
||||
END_DATE = datetime(2026, 3, 23, 0, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
# PostgreSQL-Konfiguration
|
||||
DB_HOST = os.getenv('DB_HOST', 'localhost')
|
||||
@@ -96,6 +96,41 @@ def main():
|
||||
sqlite_conn.close()
|
||||
sys.exit(1)
|
||||
|
||||
# Tabelle anlegen falls nicht vorhanden
|
||||
try:
|
||||
pg_cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS weather_data (
|
||||
id SERIAL PRIMARY KEY,
|
||||
datetime TIMESTAMPTZ NOT NULL,
|
||||
temperature FLOAT,
|
||||
humidity INTEGER,
|
||||
pressure FLOAT,
|
||||
wind_speed FLOAT,
|
||||
wind_gust FLOAT,
|
||||
wind_dir FLOAT,
|
||||
rain FLOAT,
|
||||
rain_rate FLOAT,
|
||||
temp_in FLOAT,
|
||||
humidity_in INTEGER,
|
||||
forecast INTEGER,
|
||||
bar_trend INTEGER,
|
||||
source VARCHAR,
|
||||
received_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(datetime)
|
||||
)
|
||||
""")
|
||||
pg_cursor.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_weather_datetime_desc "
|
||||
"ON weather_data (datetime DESC)"
|
||||
)
|
||||
pg_conn.commit()
|
||||
print("✓ Tabelle weather_data bereit")
|
||||
except Exception as e:
|
||||
print(f"✗ Fehler beim Anlegen der Tabelle: {e}")
|
||||
sqlite_conn.close()
|
||||
pg_conn.close()
|
||||
sys.exit(1)
|
||||
|
||||
# Tabelle leeren falls gewünscht
|
||||
if TRUNCATE_TABLE:
|
||||
print("\nLeere PostgreSQL-Tabelle weather_data...")
|
||||
@@ -163,13 +198,13 @@ def main():
|
||||
|
||||
# In PostgreSQL einfügen
|
||||
pg_cursor.execute("""
|
||||
INSERT INTO weather_data
|
||||
(datetime, temperature, humidity, pressure,
|
||||
wind_speed, wind_gust, wind_dir, rain, rain_rate)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
INSERT INTO weather_data
|
||||
(datetime, temperature, humidity, pressure,
|
||||
wind_speed, wind_gust, wind_dir, rain, rain_rate, source)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
ON CONFLICT (datetime) DO NOTHING
|
||||
""", (dt, temp_c, humidity, pressure_hpa,
|
||||
wind_speed_kmh, wind_gust_kmh, windDir, rain_mm, rain_rate_mm))
|
||||
""", (dt, temp_c, humidity, pressure_hpa,
|
||||
wind_speed_kmh, wind_gust_kmh, windDir, rain_mm, rain_rate_mm, 'wview'))
|
||||
|
||||
if pg_cursor.rowcount > 0:
|
||||
inserted += 1
|
||||
|
||||
Reference in New Issue
Block a user