Not for use in production
db = ksh_wg_mariadb_adapter.connect("lernumgebung_mariadb-server", "root", "mariadb", datenbank)
if db.test():
print("Hurra! Die Verbindung zur Datenbank klappt :)")
else:
print("Uups! Da ging noch was schief :(")
List tables:
tabellen = db.tables()
print(tabellen)
Select all data from a table:
daten = db.select("noten")
print(daten)
Condition:
daten = db.select("noten", where="note > 5")
Order:
daten = db.select("noten", order_by="note ASC")
daten = db.select("noten", order_by="note ASC, name DESC")
new_tupel = { "name": "Hans Muster", "note": 5.5 }
db.insert("noten", new_tupel)
changes = { "name": "Hans Muster", "note": 4.5 }
db.update("noten", changes, where="id = 1")
db.delete("noten", where="id = 1")