示例#1
0
def main():
    main_database = FilmsDatabase('', empty=True)
    start_window = Tk()
    start_window.title('Open or create?')
    start_window.geometry('300x150+700+400')
    filename = StringVar()
    label_filename = Label(start_window, text='Select option:', font=14)
    label_filename.place(relheight=0.3, relwidth=0.8, relx=0.1)
    btn_create = Button(
        start_window,
        text='Create database',
        command=lambda: start_create_db(start_window, main_database))
    btn_create.place(relheight=0.25, relwidth=0.5, relx=0.25, rely=0.7)
    btn_open = Button(
        start_window,
        text='Open database',
        command=lambda: start_open_db(start_window, main_database))
    btn_open.place(relheight=0.25, relwidth=0.5, relx=0.25, rely=0.3)
    start_window.mainloop()

    root = Tk()
    root.title('Interactive database')
    root.geometry('900x700+350+70')
    name_input = StringVar()
    year_input = StringVar()
    rate_input = StringVar()
    id_input = StringVar()
    entries = add_entries(root, name_input, year_input, rate_input, id_input)
    add_labels(root)
    listboxes = add_scroll_listboxes(root)
    search_type = add_menu(root, main_database)
    add_buttons(root, entries, main_database, listboxes, search_type)

    root.mainloop()
示例#2
0
def start_open_db(window, main_database):
    os.chdir('Data')
    file_name = fd.askopenfilename()
    os.chdir('..')
    opened_db = FilmsDatabase.open_db(file_name)
    main_database.change(opened_db)
    window.destroy()
示例#3
0
def start_create_db(window, main_database):
    os.chdir('Data')
    file_name = fd.asksaveasfilename(filetypes=(("HDB files", "*.hdb"),
                                                ("All files", "*.*")))
    os.chdir('..')
    new_db = FilmsDatabase(file_name, empty=True)
    main_database.change(new_db)
    window.destroy()
示例#4
0
def create_db(main_database):
    os.chdir('Data')
    file_name = fd.asksaveasfilename(filetypes=(("HDB files", "*.hdb"),
                                                ("All files", "*.*")))
    os.chdir('..')
    new_db = FilmsDatabase(file_name)
    main_database.save_db(main_database.filename)
    main_database.change(new_db)
示例#5
0
def insert(main_database: FilmsDatabase, entries: list):
    main_database.add([
        entries[0].get(), entries[1].get(), entries[2].get(), entries[3].get()
    ])
示例#6
0
def from_backup():
    file_name_zip = fd.askopenfilename(initialdir=os.getcwd() + '/Backup',
                                       title='Select file to unzip',
                                       filetypes=(("ZIP files", "*.zip"),
                                                  ("All files", "*.*")))
    FilmsDatabase.from_backup(file_name_zip, os.getcwd() + '/Data/')
示例#7
0
def open_db(main_database):
    file_name = fd.askopenfilename()
    new_db = FilmsDatabase(file_name)
    if new_db:
        main_database.save_db(main_database.filename)
        main_database.change(new_db)
示例#8
0
from time import time

from database import FilmsDatabase

###################################################################
# INSERT operation validation
###################################################################
db = FilmsDatabase('for_tests_10.hdb')
insert_times = []
start = time()
for i in range(0, 10):
    db.add(['Film' + str(i), '1990', '7', str(1000000 + i)])
end = time()
insert_times.append(end - start)

db.save_to_xlsx()

db = FilmsDatabase('for_tests_100.hdb')
start = time()
for i in range(0, 100):
    db.add(['Film' + str(i), '1990', '7', str(1000000 + i)])
end = time()
insert_times.append(end - start)

db = FilmsDatabase('for_tests_1000.hdb')
start = time()
for i in range(0, 1000):
    db.add(['Film' + str(i), '1990', '7', str(1000000 + i)])
end = time()
insert_times.append(end - start)