Skip to content
Sign upLog in
← Back to Community
How to get all keys with their values with replitdb
Profile icon

I'm working on something that uses python code and Replitdb to make an api. I have to return all the keys with their values in json for each request, but there isn't any way to do this that I can tell. Can anyone tell me how to get a dict of all the keys which I can then convert to json or give me some code to do the same thing? Thanks

Profile icon
Profile icon

You could do this:

keys = db.keys() for i in keys: print(i,":",db[i])
Profile icon

thanks but I don't even use python or replit anymore :P (learn svelte)

Profile icon

Loop through all the keys and print their value, then add them to a dict. Like:

for i in db: print(i)

This would print every key in the database.

You can list all the keys with this (check the db tab in the sidebar):
Screen Shot 2021-10-12 at 4.22.26 PM