PostGreSQL + tkinter conundrum

I am trying to create a program in tkinter which would implement PostGreSQL databases. All goes well until the issue of modifying data. The image below shows how it currently looks like
Bez tytułu
I wanted to make it so the modification process is composed of two subroutines: One takes the selected object and “moves it” to the inserts on left, so I can modify them, after pressing the button the object gets modified and all is good. Here is mine “attempt”:

def MODIFY_USER():
    connect, cursor = connection_to_db()
    i = listbox_object_list.index(ACTIVE)
    entry_name_unit.delete(0, END)
    entry_adress_unit.delete(0, END)
    entry_phone_number_u.delete(0, END)


    # Fetch user data from PostgreSQL
    cursor.execute('SELECT * FROM units WHERE "ID_UNIT" = %s', (i + 1,))
    user_data = cursor.fetchone()

    entry_name_unit.insert(0, user_data[1])
    entry_adress_unit.insert(0, user_data[2])
    entry_phone_number_u.insert(0, user_data[3])


    button_add_object.config(text="Save", command=lambda: UPDATE_USER(i))

def UPDATE_USER(i: int):
    connect, cursor = connection_to_db()
    i = listbox_object_list.index(ACTIVE)
    cursor.execute("UPDATE units SET name = %s, adress = %s, phonenumber = %s WHERE 'ID_UNIT' = %s",
                   (entry_name_unit.get(), entry_surname.get(), entry_phone_number_u.get(), i + 1))
    connect.commit()

    button_add_object.config(text="Add object", command=ADD_UNIT)
    entry_name_unit.delete(0, END)
    entry_adress_unit.delete(0, END)
    entry_phone_number_u.delete(0, END)

Which itself is an attempt of morphing this to use PostGreSQL:

def MODIFY_USER():
    i = listbox_object_list.index(ACTIVE)
    entry_name.delete(0, END)
    entry_surname.delete(0, END)
    entry_city.delete(0, END)
    entry_posts.delete(0, END)
    entry_name.insert(0, Users[i].name)
    entry_surname.insert(0, Users[i].surname)
    entry_city.insert(0, Users[i].location)
    entry_posts.insert(0, Users[i].posts)
    button_add_object.config(text="Zapisz zmiany", command=lambda:UPDATE_USER(i))

def UPDATE_USER(i:int):
    i = listbox_object_list.index(ACTIVE)
    Users[i].name = entry_name.get()
    Users[i].surname= entry_surname.get()
    Users[i].location= entry_city.get()
    Users[i].posts = entry_posts.get()
    button_add_object.config(text="Add object", command=ADD_USER)
    entry_name.delete(0, END)
    entry_surname.delete(0, END)
    entry_city.delete(0, END)
    entry_posts.delete(0, END)
    USER_LIST()

The most common kind of error is this one:

 line 200, in MODIFY_USER
    entry_name_unit.insert(0, user_data[1])
                              ~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

What should I do? Scrap the code in its entirety and start anew? 

Here’s an example using the Treeview widget to make a listbox, which has the advantage that you refer to the rows by an ID instead of their current index:

import tkinter as tk
import tkinter.ttk as ttk

# The main window.
main_window = tk.Tk()
main_window.title('Example GUI')

# The frame to hold the list box.
list_frame = tk.Frame(main_window)
list_frame.pack(side='right')

# The list box with scroll bar.
yscrollbar = tk.Scrollbar(list_frame, orient='vertical')
yscrollbar.pack(side='right', fill='y')

listbox = ttk.Treeview(list_frame, show='headings', columns=['people'], yscrollcommand=yscrollbar.set)
listbox.pack(side='left', fill='both', expand=True)
listbox.heading('people', text='People')

yscrollbar.config(command=listbox.yview)

# When 1 row of the list box is selected, fill the entry boxes with the info.
def on_select_person(event=None):
    if len(listbox.selection()) == 1:
        # 1 row selected.
        person_id = listbox.selection()[0]
        person_info = people[person_id]
        name_var.set(person_info['name'])
        address_var.set(person_info['address'])
        phone_number_var.set(person_info['phone'])
    else:
        # 0 or >1 rows selected.
        name_var.set('')
        address_var.set('')
        phone_number_var.set('')

listbox.bind('<<TreeviewSelect>>', on_select_person)

# The frame to hold the entry boxes.
entry_frame = tk.Frame(main_window)
entry_frame.pack(side='bottom')

# The entry box for the name.
tk.Label(entry_frame, text='Name:').grid(row=0, column=0)

name_var = tk.StringVar()
name_entry = tk.Entry(entry_frame, textvariable=name_var)
name_entry.grid(row=0, column=1, sticky='we')

# The entry box for the address.
tk.Label(entry_frame, text='Address:').grid(row=1, column=0)

address_var = tk.StringVar()
address_entry = tk.Entry(entry_frame, textvariable=address_var)
address_entry.grid(row=1, column=1, sticky='we')

# The entry box for the phone number.
tk.Label(entry_frame, text='Phone number:').grid(row=2, column=0)

phone_number_var = tk.StringVar()
phone_number_entry = tk.Entry(entry_frame, textvariable=phone_number_var)
phone_number_entry.grid(row=2, column=1, sticky='we')

# The save button.
def on_save(event=None):
    if len(listbox.selection()) == 1:
        # Save the info.
        person_id = listbox.selection()[0]
        person_info = people[person_id]
        person_info['name'] = name_var.get()
        person_info['address'] = address_var.get()
        person_info['phone'] = phone_number_var.get()

        # Update the list box.
        listbox.item(person_id, values=(person_info['name'],))

save_button = tk.Button(entry_frame, text='Save info', command=on_save)
save_button.grid(row=4, column=0, columnspan=2)

# Create the people.
people = {}

for person_id in range(1, 21):
    people[str(person_id)] = {'name': f'Name {person_id}', 'address': f'Address {person_id}', 'phone': f'Phone {person_id}'}

# Fill the list box.
for person_id, person_info in people.items():
    listbox.insert('', 'end', values=(person_info['name'],), iid=person_id)

main_window.mainloop()