Python Forum
Returning a message when SQL server is unavailable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Returning a message when SQL server is unavailable
#1
I'm using pymysql and I have a login script like the one bellow:
How can I raise a message to user when the sql server is unavailable?

import pymysql
import tkinter as tk


def submitact():
    user = Username.get()
    passw = password.get()

    print(f"The name entered by you is {user} {passw}")

    logintodb(user, passw)


def logintodb(user, passw):

    # If password is enetered by the
    # user
    global db
    if passw:
        db = pymysql.connect(host="localhost",
                             user=user,
                             password=passw,
                             db="prices")
        cursor = db.cursor()

    # If no password is enetered by the
    # user
    else:
        print("Erorr", "No password")

    try:
        print("Query Executed successfully")

    except:
        db.rollback()
        print("Error occurred")



    finally:
        db.rollback()
        print("Error")



root = tk.Tk()
root.geometry("300x300")
root.title("Login Page")

# Defining the first row
lblfrstrow = tk.Label(root, text="Username -", )
lblfrstrow.place(x=50, y=20)

Username = tk.Entry(root, width=35)
Username.place(x=150, y=20, width=100)

lblsecrow = tk.Label(root, text="Password -")
lblsecrow.place(x=50, y=50)

password = tk.Entry(root, width=35)
password.place(x=150, y=50, width=100)

submitbtn = tk.Button(root, text="Login",
                      bg='blue', command=submitact)
submitbtn.place(x=150, y=135, width=55)

root.mainloop()
Reply
#2
Display a message in a popup dialog window? Have a status display on the bottom of the main window? Use a text box to display logger information?

How do you want it to work?
Reply
#3
In a pop-up window!
Thanks!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020