#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+#
# PYTHON LESSION 1 DBMS Connection
# V0.9 05.07.2023 Auth. VODIMAN
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+#
import mysql.connector

# Verbindung zur Datenbank herstellen vorher:
#pip install mysql-connector-python
db = mysql.connector.connect(
  host="localhost",
  user="username",
  password="password",
  database="database_name"
)

# Cursor erstellen
cursor = db.cursor()

# SQL-Statement ausführen
sql_statement = "SELECT * FROM table_name"
cursor.execute(sql_statement)

# Ergebnis abrufen
result = cursor.fetchall()

# Ergebnis ausgeben
for row in result:
  print(row)

# Verbindung schließen
cursor.close()
db.close()
