Error saving a dictionary

Hello, I want to back up data from TinyDB and restore it later. The output button outputs all data in the form of a dictionary. The output can then be saved somewhere. If you now re-enter the text in the text field and press the save button, the data from the dictionary should be saved back to the TinyDB. But here comes the error:

The second argument to foreach is not a list. The second argument is: {“Name1”:“Wert1”,“Name2”:“Wert2”,“Name3”:“Wert3”,“Name4”:“Wert4”,“Name5”:“Wert5”}

What I have done wrong?

This is not a list. It’s already a dictionary and should be treated as a dictionary, not a list!

Many thanks for your response. I removed the list. However, the input is still not recognized as a dictionary.

Key Name1 , Value Wert1 ;
Key Name2 , Value Wert2

… that’s a dictionary structure.

Can you please explain a bit what you’re exactly trying to do?

Thank you for your help. When I display the TinyDB entries, the control module recognizes them as a directory. However, if I output the output to a text field, the error is returned when I try to save this directory text in the Tiny DB. I would like to save the TinyDB in a file and read it back in and restore it later after a new installation of the app. I thought it worked best that way.

label text will no recognised in that order. so instead of Textfield text just use call Tiny_DB1.Get Entries

.
.0image

I hope this picture will explain you the reason well…

So try this way

image

Thank you for your suggestion and the effort. But the problem is that after the new installation all data is deleted from the DB. So I can’t import anything from this DB. It has to come from an external source, is that possible?

Seems you’re newbie at this segment! Please search the community as most of the questions has already been answered. Community is helpful for those who help themselves first!

For sure. Possibilities are limited only by your imagination.

Hello, I’m not new. Only the project is new to me. I want a working TinyDB backup system. An extension is used in the community:

https://groups.google.com/g/mitappinventortest/c/7-zmkoNA47E/m/-iovL7GEBAAJ

However, this no longer works with the current version. What else can you do?

I have now found another solution to my problem and all data is stored in the TinyDB again.

If a database entry is a list, it is no longer recognized as a list. How can that be?

you could ask the author @juananton1991 of that extension, if there is a new verison available…

are you talking about the tag or the value?
before taking a screenshot please switch the language to English… thank you…
which extension are you now using? any link? I can’t see any extension specific blocks?

Taifun

Here is the screenshot again in English.

Screenshot

If an entry (value) is not just a text, but a list, this list can be read from memory and used normally. If you export entries and later import them again, the list can no longer be used. The entry (value) is no longer recognized as a list.

Thanks for the tip about the new version. I’ll take a look. My solution on the screenshot doesn’t use an extension. An extension was my first idea to implement the backup function, which didn’t work due to the error. Therefore the attempt without extension to build a backup function. The data is all saved properly again, now there is only the problem with the list (which is no longer recognized as a list).

are you talking about the extension from @juananton1991 ? which error did you get? usually if there is an error, you contact the extension developer to report the issue…

I do not understand and can’t see from your screenshot, how that backup function works… Are you storing in a file? Lists only will look like a list, but are not really lists… You therefore should convert lists into csv rows before storing and converting from csv row into a list again after reading… there are blocks in the list drawer for this…

https://publicdelivery.org/magritte-not-a-pipe/

Taifun

All data is read from the TinyDB and with ; and = are output separately to form a coherent text. The user copies this text and later pastes this text on the new cell phone and the data is transferred back to the TinyDB. The app thus has all the old data on a new device again. Later, the text is simply saved in a file and then saved automatically.

Okay, I’ll try to export the lists as CSV (so they don’t get destroyed). I’ll try it straight away.

a bit cumbersome, isn’t it?
Taifun

Copying the text is only for the testers, the result at the end will be with the file, just like any other app. I just have to get there first.

If you find a better way let me know.

Use the extension…, show us your blocks and nake sure to store the file in shared storage, my guess is, this was your problem. . See also

Taifun

Thanks, I’ll try and show my results later.

I tried to use the extension again. No CSV and Json is generated, so you can’t save anything in a file. Does the extension work for you?

I have now continued to work without extension. Unfortunately, your tip with CSV and the lists didn’t work. This error message is displayed:

The operation list to csv row cannot accept the arguments: , [[Element1, Element2, Element3]]
Note: You will not see another error reported for 5 seconds.

Here are the blocks: