Ejemplo n.º 1
0
 def insert(self, title, author, isbn):
     sql = "INSERT INTO books(title, author, isbn) VALUES (?,?,?)"
     values = [title, author, isbn]
     self.c.execute(sql, values)
     self.connection.commit()
     message_windows.MessageInfoWindow(title="Book Database",
                                       message="New book was added")
Ejemplo n.º 2
0
def search():
    search_input = search_entry.get()
    if not search_input:
        message_windows.MessageInfoWindow("Search", "Search field is empty")
    else:
        tree.delete(*tree.get_children())
        for r_row in db.filter(selected, search_input):
            tree.insert("", 'end', values=r_row)
Ejemplo n.º 3
0
def add_records():
    if not title_text.get() and not author_text.get() and not isbn_text.get():
        message_windows.MessageInfoWindow(
            "Required data", "Please add information to all required fields")
    else:
        db.insert(title_text.get(), author_text.get(), isbn_text.get())
        tree.delete(*tree.get_children())
        tree.insert("",
                    'end',
                    values=(db.c.lastrowid, title_text.get(),
                            author_text.get(), isbn_text.get()))
        title_entry.delete(0, 'end')
        author_entry.delete(0, 'end')
        isbn_entry.delete(0, 'end')
        db.connection.commit()
Ejemplo n.º 4
0
 def delete(self, id):
     delsql = "DELETE FROM books WHERE id=?"
     self.c.execute(delsql, [id])
     self.connection.commit()
     message_windows.MessageInfoWindow(title="Book Database",
                                       message="The book was deleted")
Ejemplo n.º 5
0
 def update(self, id, title, author, isbn):
     tsql = "UPDATE books SET title=?, author=?, isbn=? WHERE id=?"
     self.c.execute(tsql, [title, author, isbn, id])
     self.connection.commit()
     message_windows.MessageInfoWindow(title="Book Database",
                                       message="The book was updated")
Ejemplo n.º 6
0
def empty_fields_warning():
    message_windows.MessageInfoWindow(
        title="Nothing was selected",
        message="""Please make sure you've selected book
    through 'View all records' screen""")