You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have managed to "hack-fix" solution, so search by query would work.
To search for data by column and value use db_table.find({"name" : "bob"}) for first occurrence and db_table.query({"name" : "bob"}) for all occurrences
Edit __return_query method to following: found = False moved to another location and else's commented out
def __return_query(self, search_type, queries = None):
"""
Helper function to process a query and return the result.
"""
if queries:
queries = self.__scrub_data(queries)
result = []
location = os.listdir(self.path)
#Remove non-data files from our list of dirs.
location = [element for element in location if 'data' in element]
#Sort as integers so we get them in the right order.
location = sorted(location, key=lambda x: int(x.split('.')[0].split('_')[1]), reverse = True)
found = False
for f in location:
with open(self.path + '/' + f, 'r') as data:
for line in data:
#Make sure the line isn't blank (ex. if it was deleted).
if line != '\n':
found = False
current_data = json.loads(line)
for query in queries:
if current_data['data'][query] == queries[query]:
found = True
# else:
# found = False
# break
if found:
if search_type == 'find':
return current_data['data']
elif search_type == 'query':
result.append(current_data)
# else:
# break
if result:
return result
else:
return None
This solution work good on my computer python
But i'm not happy with a performance on uC (esp32) of inserting data, I'm not sure will it be usable on uC
Activity
lixas commentedon Nov 29, 2020
Hello @shanevanj
I have managed to "hack-fix" solution, so search by query would work.
To search for data by column and value use
db_table.find({"name" : "bob"})for first occurrence anddb_table.query({"name" : "bob"})for all occurrencesEdit
__return_querymethod to following:found = Falsemoved to another location andelse's commented outThis solution work good on my computer python
But i'm not happy with a performance on uC (esp32) of inserting data, I'm not sure will it be usable on uC