[Solved] Call a Database dynamically

Hi,

Is there a way to choose the name of a table dynamically?

So I have 18 items in a list and 18 corresponding databases.
Each list item on selection displays the corresponding database.

So right now everything is hard-coded:
If item-1 selected, call table 1
else if item-2 selected, call table 2
else if…
else call table 18.

Is it possible to make this code smaller by choosing table name dynamically,
like > if item-i selected, call table i ?

Hi,

Use this block

изображение

1 Like

Thanks @actech. Is this possible to do for a local database too? I don’t see the option in a local database.

What do you mean by “local database”? There is no such component in Thukable X.

Untitled

This one.

Clearly, this is actually a local table ).

Now I will think about how to do this, because I do not see an easy way yet.

Unfortunately, Any Components do not have the Local DB type in the list of components, so it was very easy to solve your question by specifying the name of the table you need in the set Any Component block. I think you need to make a request on github to add the Local DB component to the list of components for the get and set Any Components blocks.

Thanks @actec. I think till then I will use AirTable

You can easily build your tables using JSON, if you know how to work with this format, or try using a delimited string and a List component.

@actech
I’m trying to utilize the “tablename” and “viewname” blocks, but I can’t get the data viewer to update at all to the new table. I’ve tried the two solutions below. Neither work.

Have you been able to get it to work? Also, what do you mean by build your own tables with JSON? How do you get the dataviewers to update with the JSON?

image

I see that the problem with table access blocks hasn’t been solved, so you can’t use blocks to switch tables.

A table is a string of data with delimited fields and rows (CSV). A lot of tables is a data string with field, row, and table separators. For this reason, you can implement all tables as a delimited text string. But I recommend that you learn the JSON format, which allows you to work with tables in a simpler way.

You can use Firebase to work with tables, but here again you will need JSON knowledge.

Unfortunately the new data viewer components don’t work with Firebase, otherwise that would probably be my go to.