Hallo,
ich habe eine Datenbank in der ich jede Stunde Messdaten mit Python schreibe.
Bis da hin gehts auch.
Python
#!/usr/bin/python3
# statistik.py
import time
import sqlite3
connection = sqlite3.connect("MessDaten.db")
cursor = connection.cursor()
sql_command = "CREATE TABLE IF NOT EXISTS 'MessDaten' (" \
"`id` INTEGER PRIMARY KEY, " \
"`Zeit` INTRGER, " \
"`Ausst` REAL, " \
"`WoZt` REAL, " \
"`GaZt` REAL, " \
"`BaZt` REAL, " \
"`WCZt` REAL, " \
"`Kesst` REAL, " \
"`Boilt` REAL, " \
"`Regen` INTEGER, " \
"`Wind` INTEGER, " \
"`Schnee` INTEGER, " \
"`Sonne` INTEGER, " \
"`Res1` REAL, " \
"`Res2` REAL, " \
"`Res3` REAL, " \
"`Res4` REAL)"
cursor.execute(sql_command)
connection.commit()
connection.close()
vMinOld = 0
vDL = True
while True:
vTimeDate = time.localtime()
if vMinOld!=vTimeDate[4]:
vDL = True
if vTimeDate[4]==0 and vDL==True:
vMinOld = vTimeDate[4]
vDL = False
f=open("/mnt/RAMDisk/BodenH_Werte.wet", "r")
#f=open("A:/EigeneSonstigeDateien/Raspberry Pi/WWW/BodenH_Werte.wet", "r")
vstrf=f.read()
f.close()
aBodenHWerte = vstrf.split(';')
print(aBodenHWerte)
tAus = aBodenHWerte[0]
tWoZ = aBodenHWerte[1]
tGaZ = aBodenHWerte[6]
tBaZ = aBodenHWerte[11]
tWCZ = aBodenHWerte[16]
tKess = aBodenHWerte[22]
tBoil = aBodenHWerte[28]
vZeit = "%s%2.2i%2.2i%2.2i" % (vTimeDate[0], int(vTimeDate[1]), int(vTimeDate[2]), int(vTimeDate[3]))
print(vZeit)
connection = sqlite3.connect("MessDaten.db")
cursor = connection.cursor()
sql = "INSERT INTO `MessDaten` (`Zeit`, `Ausst`, `WoZt`, `GaZt`, `BaZt`, `WCZt`, `Kesst`,`Boilt`, `Regen`, `Wind`, `Schnee`, `Sonne`, `Res1`, `Res2`, `Res3`, `Res4`) VALUES (" \
"'" + vZeit + "', " \
"'" + tAus + "', " \
"'" + tWoZ + "', " \
"'" + tGaZ + "', " \
"'" + tBaZ + "', " \
"'" + tWCZ + "', " \
"'" + tKess + "', " \
"'" + tBoil + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "', " \
"'" + "" + "')"
cursor.execute(sql)
connection.commit()
connection.close()
sleep(1)
Alles anzeigen
Und jetzt das Problem!
Mit PHP möchte ich die Datenbank auslesen.
Ich brauche für jede Wertereihe eine eigene Array.
Kann jemand werter helfen?
Daneie