Simple use of dictionary and TinyDB

Introduction

Have you ever use tinyDB or other databases to store value? When there are so many data you have to store, you won’t want to store it with so many call tinyDB store block. Therefore, the dictionary can be used to help.

What is a dictionary?

Dictionary is a built-in component.
Generally speaking, a dictionary uses a key to call and get the value.
For example,
It will return the string "whatever".
blocks (2)

How to use it?

As mentioned,

a dictionary uses a key to call and get the value.

What you’ll need:

image
image

Same logic as TinyDB, but we use the dictionary this time

The dictionary now acts like tinyDB, can be used for storing almost everything.

How to get the value?

Use the example above,


If the key doesn’t exist, return “not found”.

How to store/ add new value?

Store New value:

It is easy. If you want to replace with the new value, do this


Remember to store the dictionary with tinyDB as well.

Add new value:

Similar to store new value, but it will create a new pair of key and value.

It is really useful when you have to store many values. There are also many features in the dictionary such as return the list of key and value.

If you find a helpful and you have time, leave a like :slight_smile:
Ask anything if you have any question, I will try to answer as much as I can.

22 Likes

Nice guide @WatermelonIce :+1:

4 Likes

Simple and understandable explained guide, @WatermelonIce! That gives you
:+1: :+1: :+1:
You made a Tutorial of blocks which are very very useful and must be understood correctly. Thank you very much!
:partying_face: :sunglasses:

3 Likes

Useful Tutorial. Keep it up…

2 Likes

I changed your title a bit since it is a combination of a Dictionary and a TinyDB. Hope you don’t mind.

4 Likes

Can I Store Html Text as pair?

1 Like

I think you can. What about just trying it out? :sweat_smile:

1 Like

As Yoshi said, what are you trying?
You want the key to be html or the value?
As mentioned,

Text can always be stored.

1 Like

Good guide @WatermelonIce :golfing_man:

2 Likes

Nice guide. Easy to understand. Great work