Comments (1)
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 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
from micropydatabase.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropydatabase.