Giter VIP home page Giter VIP logo

jsondb's People

Contributors

shaung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jsondb's Issues

`.keys()` sometimes doesn't work after saving and reloading

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)]

Support negative step in sequence slicing

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

Does this database support update records?

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

README describes `.save` method but no such method exists

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.