Challenge

Project 1 - English Dictionary App & Library Book Management System

1A.

#1. Database-Software Interface
import pickle #serialization package
import os
def SavingDictionary(tmp_dict):
    try:
        # 'wb' means open file with writing binary mode
        with open('words.txt', 'wb') as dictionary:
            pickle.dump(tmp_dict, dictionary)
        # dictionary = open('words.txt', 'wb')
        # pickle.dump(tmp_dict, dictionary)
        # dictionary.close()
        print("SUCCESS: writing to dictionary words.txt")
    except Exception as error:
        print(f"ERROR: {error}")
def GetDictionary():
    try:
        # 'rb' means open file with reading binary mode
        with open('words.txt', 'rb') as dictionary:
            tmp_dict = pickle.load(dictionary)
        print("SUCCESS: reading from dictionary words.txt")
        return tmp_dict
    except Exception as error:
        print(f"ERROR: {error}")
#2. User-Software Interface
def AddWord():
    print("Enter a Word to add")
    word = input("")
    print(f"Enter a meaning of {word} to add")
    meaning = input("")
    dictionary = GetDictionary()
    dictionary[word] = meaning
    SavingDictionary(dictionary)
    # after the work of this function is done, we need to go back to the menu
    main_menu()
def Meaning():
    print("Enter a Word to find")
    word = input("")
    dictionary = GetDictionary()
    # check if the word exists
    # if it does, print its meaning
    if word in dictionary:
        print(f"Found Entry: [{word} : {dictionary[word]}]")
    else:
    # otherwise throw an error and go back to the submenu of findMeaning()
        print("ERROR: The word doesn't exist!")
        Meaning()
    # after the work of this function is done, we need to go back to the menu
    main_menu()
def UpdateWord():
    print("Enter Word to edit")
    word = input("")
    # check if the word exists
    # if it does, update it
    dictionary = GetDictionary()
    if word in dictionary:
        print(f"Enter a New Meaning to edit [{word} : {dictionary[word]}] to:")
        new_meaning = input("")
        dictionary[word] = new_meaning
        SavingDictionary(dictionary)
        print(f"SUCCESS: Updated to [{word} : {dictionary[word]}]")
    else:
    # otherwise throw an error and go back to the submenu of updateWord()
        print("ERROR: The word doesn't exist! impossible to update!")
        UpdateWord()
    # after the work of this function is done, we need to go back to the menu
    main_menu()
def main_menu():
    '''
    Main Menu
    
    1. Add a new word
    2. Find the meaning
    3. Update a word
    4. Exit
    
    '''
    if not os.path.exists(os.path.join("words.txt")):
        try:
            with open('words.txt', 'wb') as dictionary:
                pickle.dump({}, dictionary)
            print("SUCCESS: writing to dictionary words.txt")
        except Exception as error:
            print(f"ERROR: {error}")
    print("Main Menu\n")
    print("1. Add a new word")
    print("2. Find the meaning")
    print("3. Update a word")
    print("4. Exit")
    # n is a way to choose items from the menu
    n = int(input(""))
    if n==1:
        # if n==1 call the function that asks for a new word to save
        AddWord()
    elif n==2:
        # if n==2 call the function that asks for a word to search
        Meaning()
    elif n==3:
        # if n==3 call the function that asks for which word to edit
        UpdateWord()
    elif n==4:
        # if n==4 then exit the program
        exit()
    else:
        # otherwise, show the error, and print the menu again
        print("ERROR: Please Enter a digit according to Menu.")
        main_menu()
# Script to Run
main_menu() # to initiate the program
#print(getDictionary())
#dictionary = {}
#saveDictionary(dictionary)
from tkinter import *
import json
from difflib import get_close_matches
data_load = json.load(open(r"C:\Users\samba\samba\dictionary"))
def search_word(word):
    if word in data_load:
        meaning_word.delete(1.0,END)
        meaning_word.insert(END,data_load[word])
        meaning_word.config()
    elif len(get_close_matches(word,data_load.keys())) > 0:
        meaning_word.config()
        meaning_word.delete(1.0,END)
        meaning_word.insert(END,"were you finding {} and meaning is : {}".format(get_close_matches(word,data_load.keys())[0],
                            data_load[get_close_matches(word,data_load.keys())[0]]))
        final = get_close_matches(word,data_load.keys())
            
window = Tk()
window.title("Dictionary")
window.geometry("400x200")
a = StringVar()
Word_1 = Entry(window,bd =5,textvariable = a)
Word_1.grid(row = 0,column =1)
L1 = Label(window,text = "Enter a word")
L1.grid(row = 0,column =0)
B = Button(window,text = "Search",command = lambda:search_word(a.get()))
B.grid(row = 1,column =2)
meaning_word =Text(window,height = 5,width = 70)
meaning_word.grid(row = 2,column =2)
window.mainloop()

1B.

# db.py
import sqlite3
def init_db():
    '''
    call me, i'll initiate and give you a connection and a cursor to my database
    '''
    connection = sqlite3.connect("LBMS.db")
    cursor = connection.cursor()
    print("Database connection established successfully")
    create_table(cursor)
    return(connection, cursor)
def term_db(connection):
    '''
    give me a database connection i'll terminate it
    '''
    connection.close()
    print("Database connection de-established successfully")
def create_table(cursor):
    '''
    give me a cursor to database i'll create book table in it
    '''
    sql_command = """CREATE TABLE if not exists books (
    title varchar(60) not null,
    author varchar(30) not null,
    year INTEGER not null,
    rack INTEGER,
    unique (title, author, year, rack)
    );"""
    cursor.execute(sql_command)
def read_table(cursor):
    '''
    give me a cursor to database, i'll read it all and send you
    '''
    sql_command = "SELECT * FROM books"
    cursor.execute(sql_command)
    data = cursor.fetchall()
    return(data)
def add_to_table(cursor, title, author, year, rack):
    '''
    give me a cursor to database, and a book, i'll add it to the books table
    '''
    sql_command = f"INSERT INTO books VALUES ('{title}', '{author}', {year}, {rack});"
    try:
        cursor.execute(sql_command)
        return(0, "success")
    except sqlite3.IntegrityError as e:
        return(111, e)
    except sqlite3.OperationalError as e:
        return(112, e)
def remove_from_table(cursor, title, author, year, rack):
    '''
    give me a cursor to database, and a book, i'll remove it.
    '''
    try:
        sql_command = f'''DELETE FROM books WHERE title="{title}";'''
        cursor.execute(sql_command)
        sql_command = f'''DELETE FROM books WHERE author="{author}";'''
        cursor.execute(sql_command)
        sql_command = f'''DELETE FROM books WHERE year="{year}";'''
        cursor.execute(sql_command)
        sql_command = f'''DELETE FROM books WHERE rack="{rack}";'''
        cursor.execute(sql_command)
    except:
        return(-1)
def update_table(cursor, title, author, year, rack):
    '''
    give me a cursor to database, and a book, i'll update it.
    '''
    try:
        sql_command1 = f'''UPDATE books SET title=? WHERE title =?'"{"issued this book"},{title}";'''
        cursor.execute(sql_command1)
        sql_command1 = f'''UPDATE books SET author=? WHERE author =?'"{"issued this book"},{author}";'''
        cursor.execute(sql_command1)
        sql_command1 = f'''UPDATE books SET year =? WHERE year =?'"{"issued this book"},{year}";'''
        cursor.execute(sql_command1)
        sql_command1 = f'''UPDATE books SET rack=? WHERE rack =?'"{"issued this book"},{rack}";'''
        cursor.execute(sql_command1)
    except:
        return(-1)
def search_from_table(cursor, title, author, year, rack):
    '''
    give me a cursor to database, and a book, i'll search it.
    '''
    try:
        cursor.execute("SELECT * FROM books WHERE title=?", (title,))
        searched_titles = cursor.fetchall()
        cursor.execute("SELECT * FROM books WHERE author=?", (author,))
        searched_authors = cursor.fetchall()
        cursor.execute("SELECT * FROM books WHERE year=?", (year,))
        searched_years = cursor.fetchall()
        cursor.execute("SELECT * FROM books WHERE ISBN=?", (rack,))
        searched_isbns = cursor.fetchall()
        return(searched_titles + searched_authors + searched_years + searched_isbns)
    except:
        return(-1)
def save_changes(connection):
    '''
    give me a connection to database i'll save the changes
    '''
    connection.commit()
    # database_gui_interface
def list_all_books(listArea):
    connection, cursor = init_db()
    print("listing books")
    books = read_table(cursor)
    listArea.delete('0','end')
    for i in range(len(books)):
        listArea.insert(i,f"{books[i][0]}, {books[i][1]}, {books[i][2]}, {books[i][3]}")
    term_db(connection)
def search_book(listArea, title, author, year, rack):
    connection, cursor = init_db()
    print("search book")
    title = title.get()
    author = author.get()
    year = year.get()
    rack = rack.get()
    res = search_from_table(cursor, title, author, year, rack)
    if res==-1:
        messagebox.showerror("Error!", "something went wrong!")
    if res!=-1:
        listArea.delete('0','end')
        for i in range(len(res)):
            listArea.insert(i,res[i])
    term_db(connection)
def add_book(title, author, year, rack):
    connection, cursor = init_db()
    print("adding book")
    title = title.get()
    author = author.get()
    year = year.get()
    rack = rack.get()
    code, error = add_to_table(cursor, title, author, year, rack)
    if code==111:
        messagebox.showerror("Error!", f"Book Already Exists!nnerror code: {code}nerror:{error}")
    if code==112:
        messagebox.showerror("""Error!", f"Please, fill in the input fields appropriately.nntitle: string, author: string,
                             year: integer,year: integer.nnerror code: {code}nerror:{error}""")
    save_changes(connection)
    term_db(connection)
def issue_book(title, author, year, rack):
    connection, cursor = init_db()
    print("issue book")
    print("delete book")
    title = title.get()
    author = author.get()
    year = year.get()
    rack = rack.get()
    code = update_table(cursor, title, author, year, rack)
    if code==-1:
        messagebox.showerror("error!", "something went wrong!")
    messagebox.showinfo("Issued!", f"Issued the book: {title}, {author}, {year}, {rack}")
    save_changes(connection)
    term_db(connection)
def delete_book(title, author, year, rack):
    connection, cursor = init_db()
    print("delete book")
    title = title.get()
    author = author.get()
    year = year.get()
    rack = rack.get()
    code = remove_from_table(cursor, title, author, year, rack)
    if code==-1:
        messagebox.showerror("error!", "something went wrong!")
    messagebox.showinfo("Deleted!", f"Deleted the book: {title}, {author}, {year}, {rack}")
    save_changes(connection)
    term_db(connection)
# gui
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
def gui():
    # 1. root
    root = Tk()
    root.title("LBMS | Library Book Management System")
    # 2. widgets
    title = StringVar()
    author = StringVar()
    year = StringVar()
    rack = StringVar()
    title_label = Label(root, text="Booktitle:", padx=10)
    author_label = Label(root, text="Author:", padx=10)
    year_label = Label(root, text="Year:", padx=10)
    rack_label = Label(root, text="ISBN:", padx=10)
    title_entry = Entry(root, textvariable=title)
    author_entry = Entry(root, textvariable=author)
    year_entry = Entry(root, textvariable=year)
    rack_entry = Entry(root, textvariable=rack)
    scrollbar = Scrollbar(root, orient="vertical")
    listArea = Listbox(root, bg='grey', width=100, yscrollcommand=scrollbar.set)
    list_all_btn = Button(root, text="List All", command=lambda:list_all_books(listArea))
    search_btn = Button(root, text="Search", command=lambda:search_book(listArea, title, author, year, rack))
    add_btn = Button(root, text="Add", command=lambda:add_book(title, author, year, rack))
    issue_btn = Button(root, text="Issue", command=lambda:issue_book(title, author, year, rack))
    del_btn = Button(root, text="delete", command=lambda:delete_book(title, author, year, rack))
    exit_btn = Button(root, text="Exit", command=root.destroy)
    scrollbar.config(command=listArea.yview)
    title_label.grid(row=0, column=0)
    author_label.grid(row=0, column=2)
    year_label.grid(row=0, column=4)
    rack_label.grid(row=0, column=6)
    title_entry.grid(row=0, column=1)
    author_entry.grid(row=0, column=3)
    year_entry.grid(row=0, column=5)
    rack_entry.grid(row=0, column=7)
    listArea.grid(row=1, column=0, columnspan=8, sticky="nsew")
    scrollbar.grid(row=1, column=9, sticky="ns")
    list_all_btn.grid(row=2, column=0)
    search_btn.grid(row=2, column=1)
    add_btn.grid(row=2, column=2)
    issue_btn.grid(row=2, column=3)
    del_btn.grid(row=2, column=4)
    exit_btn.grid(row=2, column=7)
    # 3. loop
    print("GUI loop INITIATING")
    root.mainloop()
    print("GUI loop TERMINATED")
# run
gui()
import sqlite3
# connection to sqlite
conn = sqlite3.connect("LBoMS_db")
#creating a cursor
cursor = conn.cursor()
def create_table():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("CREATE TABLE IF NOT EXISTS BoMS(Year INTEGER,Bname TEXT,Aname TEXt,Rack INTEGER)")
    conn.commit()
    
create_table()    

from tkinter import *
window = Tk()
window.title("Library Book Management System")
window.geometry("400x200")
txta = StringVar()
txtc =IntVar()
def Insert(Year,Bname,Aname,Rack):
    cursor = conn.cursor()
    cursor.execute("INSERT INTO BoMS values(?,?,?,?)",(Year,Bname,Aname,Rack))
    conn.commit()
def view():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT*FROM BoMS")
    rows = cursor.fetchall()
    return rows
Books = view()
def delete4():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DELETE FROM BoMS")
    conn.commit()
def display():
    label.config(text = view())
def display2():
    label.config(text = "The Books are Deleted Please Check it by clicking list of books")
def search(Year,Bname,Aname,Rack):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM BoMS WHERE Year=?", (E1.get(),))
    searched_Year = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Bname=?", (E2.get(),))
    searched_Bname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Aname=?", (E3.get(),))
    searched_Aname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Rack=?", (E4.get(),))
    searched_rack = cursor.fetchall()
    return searched_Bname + searched_Aname + searched_Year + searched_rack
def delete1():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DELETE FROM BoMS WHERE Year=?", (E1.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Bname=?", (E2.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Aname=?", (E3.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Rack=?", (E4.get(),))
    conn.commit()
a = input('Pease enter bookname to Issue by Update')
b = a.split()
def update1(a):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute(r"UPDATE BoMS SET Bname = Bname WHERE Bname=?",a)
    conn.commit()
    return b,"Issued "
def search_book(Year,Bname,Aname,Rack):
    Year = E1.get()
    Bname = E2.get()
    Aname = E3.get()
    Rack = E4.get()
    res = search(E1.get(),E2.get(),E3.get(),E4.get())
    print(res)
def display3():
    label.config(text =search(E1.get(),E2.get(),E3.get(),E4.get()))
def display6(b):
    label.config(text =update1(b))
L1 = Label(window,text = "Booktitle")
L1.grid(row = 0,column =0)
L2 = Label(window,text = "Author")
L2.grid(row = 0,column =2)
L3 = Label(window,text = "Year")
L3.grid(row = 0,column =4)
L4 = Label(window,text = "ISBN")
L4.grid(row = 0,column =6)
E1 = Entry(window,bd =5)
E1.grid(row = 0,column =1)
E2 = Entry(window,bd =5)
E2.grid(row = 0,column =3)
E3 = Entry(window,bd =5)
E3.grid(row = 0,column =5)
E4 = Entry(window,bd =5)
E4.grid(row = 0,column =7)
B = Button(window,text = "Add a Book",command = lambda:Insert(E1.get(),E2.get(),E3.get(),E4.get()))
B.grid(row = 4,column =2)
B1 = Button(window,text = "List of Books",command = lambda:display())
B1.grid(row = 4,column =3)
B2 = Button(window,text = "Search",command = lambda:display3())
B2.grid(row = 4,column =4)
B3 = Button(window,text = "Delete",command = lambda:(delete1()))
B3.grid(row = 4,column =5)
B6 = Button(window,text = "Issue",command = lambda:display6(b,))
B6.grid(row = 4,column =6)
B4 = Button(window,text = "Delete All Books",command = lambda:delete4())
B4.grid(row = 4,column =7)
B5 = Button(window, text="Exit", command=window.destroy)
B5.grid(row = 4,column =8)
label = Label(window)
label.grid(row = 1,column =1)

window.mainloop()
def drop():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DROP TABLE BoMS")
    conn.commit()
    conn.close()
drop()
import sqlite3
# connection to sqlite
conn = sqlite3.connect("LBoMS_db")
#creating a cursor
cursor = conn.cursor()
def create_table():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("CREATE TABLE IF NOT EXISTS BoMS(Year INTEGER,Bname TEXT,Aname TEXt,Rack INTEGER)")
    conn.commit()
    
create_table()

from tkinter import *
window = Tk()
window.title("SAMPLE Library Book Management System For One Book")
window.geometry("400x200")
txta = StringVar()
txtc =IntVar()
def Insert(Year,Bname,Aname,Rack):
    cursor = conn.cursor()
    cursor.execute("INSERT INTO BoMS values(?,?,?,?)",(Year,Bname,Aname,Rack))
    conn.commit()
def view():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT*FROM BoMS")
    rows = cursor.fetchall()
    return f"Year :{rows[0][0]},Book Title:{rows[0][1]},Author Name:{rows[0][2]},Rack No:{rows[0][3]}"
def delete4():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DELETE FROM BoMS")
    conn.commit()
def display():
    label.config(text = view())
def display2():
    label.config(text = "The Books are Deleted Please Check it by clicking list of books")
def search(Year,Bname,Aname,Rack):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM BoMS WHERE Year=?", (E1.get(),))
    searched_Year = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Bname=?", (E2.get(),))
    searched_Bname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Aname=?", (E3.get(),))
    searched_Aname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Rack=?", (E4.get(),))
    searched_rack = cursor.fetchall()
    return(f"Year :{searched_Bname[0][0]},Book Title:{searched_Bname[0][1]},Author Name:{searched_Bname[0][2]},Rack No:{searched_Bname[0][3]}")

def search1(Year,Bname,Aname,Rack):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM BoMS WHERE Year=?", (E1.get(),))
    searched_Year = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Bname=?", (E2.get(),))
    searched_Bname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Aname=?", (E3.get(),))
    searched_Aname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Rack=?", (E4.get(),))
    searched_rack = cursor.fetchall()
    return(f"Year :{searched_Year[0][0]},Book Title:{searched_Year[0][1]},Author Name:{searched_Year[0][2]},Rack No:{searched_Year[0][3]}")
def search2(Year,Bname,Aname,Rack):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM BoMS WHERE Year=?", (E1.get(),))
    searched_Year = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Bname=?", (E2.get(),))
    searched_Bname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Aname=?", (E3.get(),))
    searched_Aname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Rack=?", (E4.get(),))
    searched_rack = cursor.fetchall()
    return f"Year :{searched_Aname[0][0]},Book Title:{searched_Aname[0][1]},Author Name:{searched_Aname[0][2]},Rack No:{searched_Aname[0][3]}"
def search3(Year,Bname,Aname,Rack):
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM BoMS WHERE Year=?", (E1.get(),))
    searched_Year = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Bname=?", (E2.get(),))
    searched_Bname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Aname=?", (E3.get(),))
    searched_Aname = cursor.fetchall()
    cursor.execute("SELECT * FROM BoMS WHERE Rack=?", (E4.get(),))
    searched_rack = cursor.fetchall()
    return (f"Year :{searched_rack[0][0]},Book Title:{searched_rack[0][1]},Author Name:{searched_rack[0][2]},Rack No:{searched_rack[0][3]}")
def delete1():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DELETE FROM BoMS WHERE Year=?", (E1.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Bname=?", (E2.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Aname=?", (E3.get(),))
    cursor.execute("DELETE FROM BoMS WHERE Rack=?", (E4.get(),))
    conn.commit()
def search_book(Year,Bname,Aname,Rack):
    Year = E1.get()
    Bname = E2.get()
    Aname = E3.get()
    Rack = E4.get()
    res = search(E1.get(),E2.get(),E3.get(),E4.get())
    print(res)
def search_book1(Year,Bname,Aname,Rack):
    Year = E1.get()
    Bname = E2.get()
    Aname = E3.get()
    Rack = E4.get()
    res = search(E1.get(),E2.get(),E3.get(),E4.get())
    print(res)
def search_book2(Year,Bname,Aname,Rack):
    Year = E1.get()
    Bname = E2.get()
    Aname = E3.get()
    Rack = E4.get()
    res = search(E1.get(),E2.get(),E3.get(),E4.get())
    print(res)
def search_book3(Year,Bname,Aname,Rack):
    Year = E1.get()
    Bname = E2.get()
    Aname = E3.get()
    Rack = E4.get()
    res = search(E1.get(),E2.get(),E3.get(),E4.get())
    print(res)
def display3():
    label.config(text =search(E1.get(),E2.get(),E3.get(),E4.get()))
def display4():
    label.config(text =search1(E1.get(),E2.get(),E3.get(),E4.get()))
def display5():
    label.config(text =search2(E1.get(),E2.get(),E3.get(),E4.get()))
def display6():
    label.config(text =search3(E1.get(),E2.get(),E3.get(),E4.get()))
L1 = Label(window,text = "Year")
L1.grid(row = 0,column =0)
L2 = Label(window,text = "Book Name")
L2.grid(row = 0,column =2)
L3 = Label(window,text = "Author Name")
L3.grid(row = 0,column =4)
L4 = Label(window,text = "Rack")
L4.grid(row = 0,column =6)
E1 = Entry(window,bd =5)
E1.grid(row = 0,column =1)
E2 = Entry(window,bd =5)
E2.grid(row = 0,column =3)
E3 = Entry(window,bd =5)
E3.grid(row = 0,column =5)
E4 = Entry(window,bd =5)
E4.grid(row = 0,column =7)
B = Button(window,text = "Add a Book",command = lambda:Insert(E1.get(),E2.get(),E3.get(),E4.get()))
B.grid(row = 4,column =2)
B1 = Button(window,text = "List Of Books",command = lambda:display())
B1.grid(row = 4,column =3)
B2 = Button(window,text = "Search BY Bookname",command = lambda:display3())
B2.grid(row = 4,column =4)
B2 = Button(window,text = "Search BY Year",command = lambda:display4())
B2.grid(row = 4,column =5)
B2 = Button(window,text = "Search BY Rack",command = lambda:display6())
B2.grid(row = 4,column =6)
B2 = Button(window,text = "Search BY Authorname",command = lambda:display5())
B2.grid(row = 4,column =7)
B3 = Button(window,text = "Delete",command = lambda:(delete1()))
B3.grid(row = 5,column =3)
B4 = Button(window,text = "Delete All Books",command = lambda:delete4())
B4.grid(row = 5,column =4)
B5 = Button(window, text="Exit", command=window.destroy)
B5.grid(row = 5,column =6)
label = Label(window)
label.grid(row = 1,column =1)

window.mainloop()
def drop():
    conn = sqlite3.connect("LBoMS_db")
    cursor = conn.cursor()
    cursor.execute("DROP TABLE BoMS")
    conn.commit()
    conn.close()
drop()
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.