python

Search using python tkinter mysql

This tutorial will teach you how to search using python Gui application connect with mysql.

from tkinter import *
import mysql.connector

def Ok():
    global myresult
    studname = e1.get()
    coursename = e2.get()
    fee = e3.get()

    mysqldb=mysql.connector.connect(host="localhost",user="root",password="",database="smschool")
    mycursor=mysqldb.cursor()

    try:
        mycursor.execute("SELECT * FROM record where id = '" + studname + "'")
        myresult = mycursor.fetchall()

        for x in myresult:
            print(x)
        e2.delete(0, END)
        e2.insert(END, x[2])
        e3.delete(0, END)
        e3.insert(END, x[3])

    except Exception as e:
       print(e)
       mysqldb.rollback()
       mysqldb.close()

root = Tk()
root.title("Search Mysql")
root.geometry("300x200")

Label(root, text="Student ID").place(x=10, y=10)
Button(root, text="Search", command=Ok ,height = 1, width = 13).place(x=140, y=40)
Label(root, text="Course").place(x=10, y=80)
Label(root, text="Fee").place(x=10, y=120)

e1 = Entry(root)
e1.place(x=140, y=10)

e2 = Entry(root)
e2.place(x=140, y=80)

e3 = Entry(root)
e3.place(x=140, y=120)

root.mainloop()


i have attached the video link below. which will do this tutorials step by step.

admin

Recent Posts

Touchable shop Pos system using Java

The Touchable Shop POS (Point of Sale) system is a sophisticated software solution developed using…

1 week ago

Build Your First Responsive Login Form Using HTML and CSS FlexBox

Creating a responsive login form is a crucial skill for any web developer. In this…

2 weeks ago

Build Crud API with Laravel 12

In this tutorial will teach  Laravel 12 CRUD API  by step. Laravel  10 CRUD Application …

2 weeks ago

laravel 12 image upload tutorial

In this lesson we talk about laravel 12 image uploading and display the image step…

3 weeks ago

Laravel 12 CRUD Application

In this tutorial will teach Laravel 12 CRUD Application step by step. Laravel  12 CRUD…

4 weeks ago

Conditional Statements in Python

Conditional statements in Python allow us to control the flow of execution based on conditions.…

2 months ago