From 29a28b388c7682d9acfc2a06ae979e68f6eb38f4 Mon Sep 17 00:00:00 2001 From: Sri Nanak Date: Mon, 29 Sep 2025 08:53:58 -0700 Subject: [PATCH 1/3] set up a module for connections, following the mysql.connector module --- trial2.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 trial2.py diff --git a/trial2.py b/trial2.py new file mode 100644 index 0000000..67a7320 --- /dev/null +++ b/trial2.py @@ -0,0 +1,28 @@ +import mysql.connector +import mysql + +try: + connection = (mysql.connector.connect + ( + host='localhost', + user='enos', + password='2025@Redmond', + database='trial_1' + ) + ) + + if connection.is_connected(): + print("Successfully connected to MySQL database.") + # You can now create a cursor and execute SQL queries + # cursor = connection.cursor() + # cursor.execute("SELECT * FROM your_table") + # results = cursor.fetchall() + # print(results) + +except mysql.connector.Error as err: + print(f"Error connecting to MySQL: {err}") + +finally: + if 'connection' in locals() and connection.is_connected(): + connection.close() + print("MySQL connection closed.") \ No newline at end of file From ff9fb3287fe652ba15d61197a2babfd4af6ac59a Mon Sep 17 00:00:00 2001 From: Sri Nanak Date: Mon, 29 Sep 2025 09:04:09 -0700 Subject: [PATCH 2/3] set up a module for connections, following the mysql.connector module. Also tested the app with a trial_1 table --- trial2.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/trial2.py b/trial2.py index 67a7320..f23fe6f 100644 --- a/trial2.py +++ b/trial2.py @@ -13,11 +13,12 @@ if connection.is_connected(): print("Successfully connected to MySQL database.") + # You can now create a cursor and execute SQL queries - # cursor = connection.cursor() - # cursor.execute("SELECT * FROM your_table") - # results = cursor.fetchall() - # print(results) + cursor = connection.cursor() + cursor.execute("SELECT * FROM trial_1") + results = cursor.fetchall() + print(results) except mysql.connector.Error as err: print(f"Error connecting to MySQL: {err}") From c0ba3a440c94a9403cacdbbc37cf554c6776da44 Mon Sep 17 00:00:00 2001 From: Sri Nanak Date: Mon, 29 Sep 2025 09:07:38 -0700 Subject: [PATCH 3/3] well done --- trial1.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/trial1.py b/trial1.py index 3b21281..8002571 100755 --- a/trial1.py +++ b/trial1.py @@ -1,6 +1,13 @@ import tkinter as tki from time import sleep +import dbm as db_connect +mydb = mysql.connector.connect( + host="localhost", # Your MySQL host + user="root", # Your MySQL username + password="2025@Redmond", # Your MySQL password + database="trial_1" # The database you want to connect to + ) def on_button_click(): """Function to be called when the button is clicked.""" @@ -16,8 +23,12 @@ def clear_label(): selected_option.set(options [0]) def save_trial (): name_variable = entry_widget.get() - label.config(text=f' Bye {name_variable} , your money is coming') - sleep(2) + + if name_variable == "": + label.config(text=f' Enter the name please') + else: + label.config(text=f' Bye {name_variable} , your money is coming') + sleep(2) # Create the main application window root = tki.Tk()