shaung / jsondb Goto Github PK
View Code? Open in Web Editor NEWdb.query('$.items[?(@.id = 1)].name')
db.query('$.items[?(@.id = 1)].name')
When you remove nodes recursively sometimes parent nodes are removed before children causing an exception to be thrown.
Repro
ipython
Python 2.7.12 (default, Jun 29 2016, 08:18:26)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | File not found: '/home/tom/.pythonrc.py'
In [1]: import jsondb
In [2]: jsondb.create({}, url='/tmp/test.db')
Out[2]: <jsondb.JsonDB at 0x7f92c07bf1d0>
In [3]: d = _
In [4]: d.keys()
Out[4]: []
In [5]: d['a'] = 1
In [6]: d.keys()
Out[6]: ['a']
In [7]: d.close()
In [8]: d = jsondb.load(url='/tmp/test.db')
In [9]:
In [9]: d.keys()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-9-8bc560538296> in <module>()
----> 1 d.keys()
/home/tom/.local/lib/python2.7/site-packages/jsondb/core.pyc in __getattr__(self, name)
90
91 def __getattr__(self, name):
---> 92 cls = self.get_datatype()
93 try:
94 attr = getattr(cls, name)
/home/tom/.local/lib/python2.7/site-packages/jsondb/core.pyc in get_datatype(self)
282
283 def get_datatype(self):
--> 284 return get_datatype_class(self.datatype)
285
286 def data(self, update=False):
/home/tom/.local/lib/python2.7/site-packages/jsondb/datatypes.pyc in get_datatype_class(_type)
47 if _type == NIL:
48 return None
---> 49 cls = DATA_INITIAL[_type].__class__
50 return cls
51
KeyError: None
In [10]: d.items()
Out[10]: [('a', 1)]
Should allow using redis as the backend.
The current implementation of slicing does not support negative step.
Given the following data
db = jsondb.create({
'name' : 'foo',
'items': [
{'id' : 0, 'name' : 'a'},
{'id' : 1, 'name' : 'b'},
{'id' : 2, 'name' : 'c'},
]
})
The output of print(db.query('$.items[::-1].name'))
should be c b a
instead of a b c
hi,this is great project. it easy to use ,but i cant find a way to update my records。i used ('[]', filepath) to create a db. when i want to update a records of [] , i get in trouble.someone can help me
Repro:
ipython
Python 2.7.12 (default, Jun 29 2016, 08:18:26)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | File not found: '/home/tom/.pythonrc.py'
In [1]: import jsondb
In [2]: jsondb.create({}, url='/tmp/test.db')
Out[2]: <jsondb.JsonDB at 0x7f8679400290>
In [3]: d = _
In [4]: d.save()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-7e84cd160ba3> in <module>()
----> 1 d.save()
/home/tom/.local/lib/python2.7/site-packages/jsondb/core.pyc in __getattr__(self, name)
92 cls = self.get_datatype()
93 try:
---> 94 attr = getattr(cls, name)
95 except:
96 raise
AttributeError: type object 'dict' has no attribute 'save'
In [5]: print jsondb.version
0.1.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.