Hey Guys, I wanted to create a treeview in tkinter using data present in my sqlite3 database.
def show():
conn = sqlite3.connect("userdata.db")
c = conn.cursor()
c.row_factory = sqlite3.Row
c.execute("SELECT * from c20;")
data = c.fetchone()
precise_data = c.fetchall()
names = data.keys()
my_tree = ttk.Treeview(table_frm)
my_tree["columns"] = tuple(names)
my_tree.column("#0", width=0, minwidth=25)
for i in names:
my_tree.column(i, width=50, minwidth=25)
# Creating headings
my_tree.heading("#0", text="Test", anchor=W)
for j in names:
my_tree.heading(j, text=j, anchor=W)
#my_tree.insert(parent="", index='end', iid=0, text="Parent", values=("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"))
for x in precise_data:
for y in x:
my_tree.insert(parent="", index="end", iid=0, text="", values=())
my_tree.pack(pady=20)
So this being the function show, where function fetches out the data from the database.
Now, while getting the data into the treeview table, I need to add values in it using the .insert function. I am able to get the data in the form of the variable y, but how can I place the values of the list of data contained in the variable y?
Sample List(for y) = ["10", "12",...]
One more thing to mention, how can I get this thing done, if the length of the list being n, or any huge or small number?
Thanks in advance.