﻿# MariaDB - TsetDB.py

import PySimpleGUI as sg
import sys
import mariadb


# Connect to MariaDB Platform
try:
    conn = mariadb.connect(
        user="root",
        password="",
        host="127.0.0.1",
        port=3306,
        database="testdb"

    )
except mariadb.Error as e:
    print(f"Error connecting to MariaDB Platform: {e}")
    sys.exit(1)

# Get Cursor
cur = conn.cursor()

cur.execute(
    "SELECT Texts FROM testme WHERE ID=1 LIMIT 1")

for (Texts) in cur:
    sg.theme('Default1')   # Add a touch of color
        # All the stuff inside your window.
    layout = [  [sg.Text(f"{Texts}")],
              [sg.Button('OK')]]

# Create the Window
window = sg.Window('Hello World', layout)
# Event Loop to process "events"
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'OK': # if user closes window or clicks OK
        break

window.close()
