ein-dateien backend erstellt

This commit is contained in:
2025-03-07 20:58:34 +01:00
parent 68a1910bdc
commit 55936c81f0
45 changed files with 2070 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import sqlite3
from dotenv import load_dotenv
import os
load_dotenv()
printers = os.getenv('PRINTER_IPS').split(',')
def create_db():
conn = sqlite3.connect('printers.db')
c = conn.cursor()
# Tabelle 'printers' erstellen, falls sie nicht existiert
c.execute('''CREATE TABLE IF NOT EXISTS printers
(ip TEXT PRIMARY KEY, status TEXT)''')
# Drucker-IPs in die Tabelle einfügen, falls sie noch nicht vorhanden sind
for printer_ip in printers:
c.execute("INSERT OR IGNORE INTO printers (ip, status) VALUES (?, ?)", (printer_ip, "frei"))
conn.commit()
conn.close()
print("Datenbank 'printers.db' erfolgreich erstellt.")
if __name__ == '__main__':
create_db()