目前在我的 Raspberry Pi 上运行 Firebird 并使用 FlameRobin 来控制它。对于另一个 Raspberry Pi,我想对其进行一些陈述,我没有收到任何错误代码,但数据却没有到达那里。
import RPi.GPIO as GPIO
import time
import fdb
con = fdb.connect(dsn='10.100.2.197/3050:/home/trainee2/Desktop/ice', user='sysdba', password='trainee')
text_file = open("namen1.txt", "r")
lines = text_file.read().split(',')
namen = lines
text_file.close()
status = [0] * 12
indexSpatie = 0
pinnen = [18,23,24,25,20,21,17,27,6,13,19,26]
controlepin = [1] * 12
GPIO.setmode(GPIO.BCM)
for p in range(0,12):
GPIO.setup(pinnen[p],GPIO.IN)
print pinnen[p]
cur = con.cursor()
while True:
for e in range(0,12):
status[e] = GPIO.input(pinnen[e])
if (status[e] != controlepin[e]):
n = e
naam = str(namen[n])
indexSpatie = naam.index(' ')
voornaam = naam[:indexSpatie]
achternaam = naam[indexSpatie:]
stat = str(status[n])
datum = time.strftime("%d/%m/%Y")
print( voornaam + achternaam + " met pinnummer: " + str(pinnen[n]) + " heeft status van " + stat + " op vandaag: " + datum)
cur.execute("insert into ICEDATA (PRENAME, NAME, DATUM) values(?,?,?)",(voornaam,achternaam,datum))
controlepin[e] = status[e]
time.sleep(1)
我发布了整个代码,因为我没有看到语句和连接本身有任何问题。