tinydb

How to retrieve a single value from a TinyDB database?

丶灬走出姿态 提交于 2021-02-10 03:02:50
问题 I'm learning how to use TinyDB on Python and I have the basics working (add, remove, update etc.). But now I'm trying to retrieve specific values from the database. The code I'm using is in this method: def showpassword(): show = userdb.get(where("username") == txtname.get()) txtshow.insert(0, show) When I run the method, it displays the output as follows: {'username': 'John', 'surname': 'Doe'} How can I get it so that I can display only the user's name or surname and without any brackets?

How to check if a tinyDB tag has any attributes in App Inventor

隐身守侯 提交于 2020-01-17 09:19:50
问题 I need a little help with an issue in App Inventor 2. The case is that I have a JSON result that is parsed, and then have it stored in a tinyDB tag as a list (storeparseData). Problem is that, I have this function done as screen initiates, so to have the tinyDB tag populated with that JSON list and then searched for a specific value on user request. As the app is running and I input a search criteria, I get the following error " The arguments [ empty-string ] are the wrong number of arguments

How do I print it into an organised json file?

谁说胖子不能爱 提交于 2019-12-12 04:53:47
问题 I need help with the output of my json file. I'm trying to print out the keys in a list called keypairs. I have to generate 60 keys, which i have included in the (count<60) part of my code (which isnt here). Im just showing the exporting part of my codes which i have a problem with. Here are my codes: with open("/home/pi/Desktop/database.json", 'w+'): db = TinyDB('/home/pi/Desktop/database.json') table = db.table('Books') db.insert({'Book ID' : keypair[bookid], 'Serial No.' : keypair

How to delete record or document from TinyDB

China☆狼群 提交于 2019-12-05 00:05:38
问题 How to delete record or document from TinyDB Example of DB: {"1" : {"id_key" : "xxx", "params" : {} } }, {"2" : {"id_key" : "yyy", "params" : {} } }, I want to delete "1" if id_key=='xxx' On TinyDB tutorial code below is suggested. How to complete it to delete record/document ? db.update(delete('key1'), where('key') == 'value') 回答1: To use the example code for your data, type: db.update(delete('id_key'), where('id_key') == 'xxx') Please note: TinyDB is a key-value database. using the code

How to delete record or document from TinyDB

时间秒杀一切 提交于 2019-12-03 16:09:59
How to delete record or document from TinyDB Example of DB: {"1" : {"id_key" : "xxx", "params" : {} } }, {"2" : {"id_key" : "yyy", "params" : {} } }, I want to delete "1" if id_key=='xxx' On TinyDB tutorial code below is suggested. How to complete it to delete record/document ? db.update(delete('key1'), where('key') == 'value') To use the example code for your data, type: db.update(delete('id_key'), where('id_key') == 'xxx') Please note: TinyDB is a key-value database. using the code above will remove the key 'xxx'. If you type: db.all() you will see that the key 'xxx' is deleted. but realize