Cannot load actual data from TinyDB

Dear All. I have a problem with data coming from TinyDB. When I select to retrieve the data ("Recuperar datos") it actually shows me what I uploaded for the selected date. However, when I want to generate a new load, on a day previously loaded in TinyDB (to add more data to that day), it shows me the last data loaded and not the ones that really correspond to that day. The problem I see is in the comparison, because even if it is true, it does not load the data in the variable global Datos. If I do a manual DO IT, and then call “rellenoDeDatos”, then the expected results are displayed. Can someone help me to solve it? I am uploading the aia just in case someone of you could test it.




Datos_copy.aia (10.9 KB)

From your Do It bubble, I see you are using dd/MM/yyyy format for your TinyDB tags and your global variables diaSeleccionado and global hoy.

Unfortunately, I also see places where you compare those two variables using text '>'.

If you are intending that to be a comparison of earlier vs later dates, it is doomed to fail.

You would have to use a format like 'yyyy-MM-dd' to get time order from text comparison order.

Thank you @ABG. I will try it now.

Unfortunatelly, it still does the same thing

what about providing a screenshot of your updated relevant blocks?
Taifun

here you have

these are all blocks... not only the relevant ones...
sorry, I do not have time to look at all the blocks... maybe @ABG does have more time...

Taifun

Sorry, here you can see the relevants blocks of the problem. I formated the data as @ABG suggested, but when I press the btnCargar it compares the dates but make nothing until I mannually press do it

image

did you update diaSeleccionado in TinyDB with the correct data format?
in the screenshot you might want to add a Do it result for diaSeleccionado and hoy...
also the better method for comparing dates are the Duration methods from the clock component, which can return a positive or negative value Sensors

Duration(start,end)
Returns the milliseconds by which end follows start (+ or -)

Taifun

I did update it. Now I deleted every entry. Let me do it again and I will show you. Thanks for your suggestion about the time. I will try to introduce it in the block. But for now the problem is that even though the comparison of the selected day in the tinydb altough it exists, it does not retrieve the contents as it does the app when I select the button Recuperar datos

Here it is

But in the screen I am still seeing the data of the last data (of day 2022-05-03)


When rellenarDatos is called, I do not get the data corresponding to the selected day (that should be 111, 222, and 333 for datos 1, 2 and 3, respectively)

what is the Do it result here?

Taifun

Sorry, I only know English, so I would be lost trying to guess what is what.

@ABG: Here I am uploading the aia with al variables and staff names in english. I you can look at it, It will be of great help for me. I am stuck with it and cannot go further. Please pay attention to the procedure in btnLoadData. The routine do nothing except opening the date picker. If you Retrieve any data and then want to load another already loaded day, you will see that neither cleanTbx nor the fillingData subroutines will respond. Thank you so much in advance
Datos_copy.aia (10.8 KB)

ok, which means, the Do it result shows the correct valuess...
if you are testing, you have to execute the Do it results in the correct sequence

probably it makes more sense to set global datos inside the rellenoDeDatos procedure at the beginning...
Taifun

I see a problem in the save data button click event.

You don't take into account the data you had previously saved for a day:

This is how it should be for that problem:

I suggest fixing the saving of data before trying to debug loading of data that is not there.

Further thought ...

I see in your work a problem similar to another users' work that I saw within the last day or so.

He had two versions of the truth, a global variable and a TinyDB value.

They were causing confusion.

I advised getting rid of the global variable, and using only the TinyDB value.

Here is a sample app that uses TinyDB without any global variables ...

Thanks @TAIFUN and @ABG for your suggestions, but unfortunately neither of the 2 options worked for me. I think the problem is not in the TinyDB but in the btnLoadData procedure (previously btnCargar). When I load data after looking up information through btnRetrieveData (previously btnRecuperar), regardless of whether I load a date that had previous data, as if I was creating a new one, the data in the textboxes does not disappear, even when a refresh call is made through the cleanTbx subroutine. If that subroutine worked, no previous data should be seen (although the call to TinyDB would fail afterwards). It seems to me that the problem is in the very call of the btnLoadData button, as if there is a computer conflict when following the sequential events. Obviously, it is far beyond my reach to solve it. Note that the ListPk_Data.AfterPicking routine does practically the same thing as Loading Data (retrieves data from a TinyDB and fills the textboxes with the fillingData subroutine) and there is no problem displaying the results there.



Datos_copy.aia (11.4 KB)

In the competition for worst variable name, the name 'list' has long held the championship.

Now we have a new champion, 'data'.
(At least the name 'datos' might possibly be the name of a small island off the Greek coast populated by a tribe of Amazon women coders.)

What's wrong with such names, you ask?

Those names are useless in helping to distinguish among the possible types, purposes, quantities, and meanings of whatever such variables hold.

Your 'data' variable holds a table of some sort, with rows containing 2 columns, the first colun is some useless attribute name, and the second column is the value of that attribute.

You are doing nested selects, and I am not convinced you are using the right indices for each select at each level.

This is a case where local variables, well named, would help make clear what is happening.
Local variables can act as stepping stones in your fast moving stream of thought.
Without them, it is too easy to get swept under and drown in confusion.

Before I can attempt to understand your code, I would need to see:

  • a descriptive variable name for the collection of records in the variable formerly known as 'data', like 'cheeses'
  • a local variable for the currently selected row in the previous item in this list, like 'current_cheese'
  • a local variable name for column 1 of the current row, like 'cheese_attribute_name' (country?)
  • a local variable name for column 2 of the current row, like 'cheese_attribute_value' (France?)
1 Like