2014년 12월 1일 월요일

Randomly select a tag from a tinydb

Hi. I´m trying to randomly select tags, and the corresponding items, from large tinydbs. I'm trying first with a small one (see attachment), but I don't manage to make it work -and I suspect it is a very inefficient way to do it.

Thanks in advance for any help you can provide.




There is a Gettags method for TinyDB. This will give you a list of all the tags in the database. Then, from the list blocks, you use pick a random item. Now you have a random tag and you can access its corresponding content in the database.



Sorry, I did not look at your blocks well enough. You should set global name to the get tags result and not add it as a single item to a list you already have. Then it should work.



Works great! Thanks a lot for your help. I attach the code, just in case it can help someone else.



댓글 없음:

댓글 쓰기