Import Tachymeter

This commit is contained in:
2025-12-10 19:06:47 +01:00
parent 32e73f0114
commit 819cf92c2d
9 changed files with 3407 additions and 1304 deletions

View File

@@ -24,6 +24,26 @@ class Datenbank_anlegen:
CONSTRAINT pk_Netzpunkte PRIMARY KEY (punktnummer)
);
""");
cursor.executescript("""CREATE TABLE Beobachtungen(
beobachtungenID INTEGER,
beobachtungsgruppeID INTEGER,
punktnummer_sp TEXT(10),
punktnummer_zp TEXT(10),
instrumenteID INTEGER,
tachymeter_richtung NUMERIC(8, 6),
tachymeter_zenitwinkel NUMERIC(8, 6),
tachymeter_distanz NUMERIC(8, 4),
dateiname TEXT(200),
CONSTRAINT pk_Beobachtunen PRIMARY KEY (beobachtungenID)
);
""");
cursor.executescript("""CREATE TABLE Instrumente(
instrumenteID INTEGER,
typ TEXT(200),
name TEXT(200),
CONSTRAINT pk_Instrumente PRIMARY KEY (instrumenteID)
);
""")
con.commit()
cursor.close()
con.close()
@@ -75,4 +95,32 @@ class Datenbankzugriff:
con.commit()
cursor.close()
con.close()
con.close()
def set_instrument(self, typ, name):
con = sqlite3.connect(self.pfad_datenbank)
cursor = con.cursor()
liste_instrumente = cursor.execute("SELECT * FROM Instrumente WHERE typ = ? AND name =?", (typ, name)).fetchall()
if liste_instrumente == []:
cursor.execute(
"INSERT INTO Instrumente (typ, name) VALUES (?, ?)", (typ, name)
)
print(f"Das Instrument {name} wurde erfolgreich hinzugefügt.")
else:
id_instrument = cursor.execute(
"SELECT instrumenteID FROM Instrumente WHERE typ = ? AND name =?", (typ, name))
print(f"Das Instrument {name} ist bereits in der Datenbank vorhanden.\nEs hat die ID {id_instrument.fetchone()[0]}")
con.commit()
cursor.close()
con.close()
def get_instrument(self, typ):
con = sqlite3.connect(self.pfad_datenbank)
cursor = con.cursor()
liste_instrumente = cursor.execute("SELECT * FROM Instrumente WHERE typ = ?", (typ,)).fetchall()
liste_typen = cursor.execute("SELECT DISTINCT typ FROM Instrumente").fetchall()
cursor.close()
con.close()
if liste_instrumente == []:
liste_instrumente = f"Kein Instrument vom Typ {typ} gefunden. Folgende Typen stehen aktuell zur Auswahl: {liste_typen}"
return liste_instrumente