Why can I not clear list of TinyDB?


I can fill TinyDB with values using the bottom block. But my cleardatabasebutton Button won’t work to clear the list. Why is that?

Use Do It to check your blocks.
I think listview is empty.

This post was flagged by the community and is temporarily hidden.

Your first entry in your registrant variable is empty and you add 5 elements. You must set global registrant to -> make a list of your 5 entrys. Second: where do you clear your tinyDB as you stated in your title?

@Lily You are posting in wrong topic.

I am sorry @George_Loungos you know I am confused and I am in a hurry

I clear it using the ClearDatabaseButton Button shown in the picture. inside it is “call List_View1.ClearList”

Even though the values are not all available, but the Username and email can successfully be stored into Listview1. I verified this because these values showed up in the ListView. But when I clicked the ClearDatabaseButton Button, it gave me that error. And ListView1 is not cleared

Okay, once more.you intialize the registrant variable to be an empty list then you add five items to that list. So your registrant list has 6! Items. The first item is empty. Just check it by right clicking on the variable and click do it. I gave you the hint in my previous post how to setup your list the right way


Hi, Thank you for being patient with me. That’s my “do it”. It seems there are 5 items in the list. I haven’t fixed the empty string yet but it is the 5th item. But when I try “do it” on the “clear list”. It returns an error. I still can’t clear the database. But as you can see, the database can be successfully written into.

Can I know why are you creating a list inside another list? Is it intended to be so or it’s a mistake?

1 Like

The idea is there are several data to each registrant. So, each registrant gets his own list. If another registrant registers, then a new list will be created. I know that’s probably not the cause of not being able to clear the database though. I have tried this before with a previous app. What do you think?

hi @yulius Would you like to send ais or aia? anything in which you don’t have any problem.

Since Clear list block isn’t working as it should, use it like this instead

bild

3 Likes

Nice. That clears up the Listview! Thing is, when I try input a new registrant’s info, the previous registrants reappear ALL of them. Something is still storing the old values. How do I clear them, so they are irretrievable?

its because the variable global Registrant Data still has the previous values. Remember when you try to clear the list ,you are just clearing the list view elements not the global Registrant Data variable.
Hence you are getting the previous values when you try to add new item.

To avoid this you can set the global Registrant Data to an empty list. So along with the blocks as per Boban, you can try something like this :point_down:

blocks (50)

2 Likes

there is a error as in above block the list will be select item from list and here list will be global RegistrantData and index will be length of list(for last registrant) or registrant index

1 Like

Thank you for telling me about that error. I haven’t got to that part yet. But do you think that may have caused the error of not being able to clear out the list?

yes may be because that was creating 5th element instead of creating it in list in index.

1 Like


if you will follow this then it will replace data in tinydb on next register click…mean you can loss data of old registrant.

1 Like

He unfortunately didn’t follow my tip