hier mein Programm:
Code: Alles auswählen
#!/usr/bin/env python
import RPi.GPIO as GPIO
from joyit_mfrc522 import SimpleMFRC522
import datetime
import time
import mysql.connector
import os
import board
GPIO.setmode(GPIO.BCM)
my_db = mysql.connector.connect(host = "localhost", user = "ich", passwd = "ich", db = "ich")
reader = SimpleMFRC522()
while True:
print("Token Anhalten")
card, text = reader.read()
print("Token Angehalten")
now = datetime.datetime.today()
ad = now.strftime('%Y-%m-%d')
aj = now.strftime('%Y')
az = time.strftime('%H:%M:%S', time.localtime())
print("Token = " + str(card))
print("Datum = " + ad)
print("Ist er Token zugeordnet ?")
time.sleep(2)
mycursor = my_db.cursor()
mycursor.execute("SELECT * FROM db WHERE db03 = %s", (card,))
myresult = mycursor.fetchone()
if myresult is not None:
print("Token ist zugeordnet")
print("Gibt es ein Eintrag in der ISS ?")
#Bis hier soweit alles ok
#Es muss die ID ermittelt werden zu einem Eintrag
#von Datum (heute) und Leerfeld von vsb07
#von hier ab, komme ich nicht weiter
mycursor = my_db.cursor()
#mycursor.execute("SELECT * FROM erfassung WHERE rfid LIKE card AND datum = ad AND zeit2 = ''")
mycursor.execute("SELECT * FROM erfassung WHERE rfid LIKE %s", (card,))
myresult = mycursor.fetchall()
for x in myresult:
x0 = x[0]
x1 = x[1]
x2 = x[2]
x3 = x[3]
x4 = x[4]
print(x)Code: Alles auswählen
(1, '500402455868', datetime.date(2025, 11, 1), '12-45-28', '16-45-28')
(2, '500402455868', datetime.date(2025, 11, 4), '15:37:54', '16:37:54')
(3, '500402455868', datetime.date(2025, 11, 4), '16:39:47', '')
(4, '500402455868', datetime.date(2025, 11, 5), '10:39:47', '')
(5, '500402455868', datetime.date(2025, 11, 6), '08:39:47', '')
(6, '500402455868', datetime.date(2025, 11, 7), '08:39:47', '')
(7, '500402455868', datetime.date(2025, 11, 8), '16:39:47', '')
(8, '500402455868', datetime.date(2025, 11, 9), '10:39:47', '')
(9, '500402455868', datetime.date(2025, 11, 10), '08:39:47', '')
(10, '500402455868', datetime.date(2025, 11, 11), '08:39:47', '')wenn Feld "x2" aktuellen Datum und "x4" leer ist zeige mir "x0"
sonst zeige mir lade akku
Code: Alles auswählen
if x2 == ad and x4 == "":
print("Zeige mir x0")
else:
print("lade Akku")phpmyadmin zeit mein Datum so an 2025-11-06
in der Ausgabe von python wieder anders (siehe oben), wie muß ich nun meine IF Abfrage aufbauen damit es klappt ?
