Added a function to querry the data in DB as nested dicts