softmotions / ejdb-python Goto Github PK
View Code? Open in Web Editor NEWProject archived in favor of ejdb2. EJDB Python binding
Home Page: http://ejdb.org
License: GNU Lesser General Public License v2.1
Project archived in favor of ejdb2. EJDB Python binding
Home Page: http://ejdb.org
License: GNU Lesser General Public License v2.1
The ejdb states that it's possible to use regexp for string matching, using the syntax described in http://ejdb.org/doc/ql/ql.html#simple-matching
I'm trying to achieve this using the python bindings, expecting to match the "Grenny" parrot.
>>> with ejdb.find('parrots2', {"name": "/G.*/"}) as cur:
... print("found %s parrots" % len(cur))
...
found 0 parrots
I wonder if I'm doing anything wrong, or if the regexp matching is really supported by the python bindings ?
Hi,
It seems that there is no EJDB_update in python binding, are u planning to implement this?
cheers,
python setup.py install
is failing due to my compiler (gcc 4.9.1 on Arch Linux) automaticly adding the flag -Werror=declaration-after-statement
.
I managed to install the package adding "-Wno-declaration-after-statement" in the extra_compile_args of ejdb_ext in the setup.py file.
Python 3.5.0 (default, Sep 20 2015, 11:28:25)
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyejdb
>>> from datetime import datetime
>>>
>>> #Open database
... ejdb = pyejdb.EJDB("zoo", pyejdb.DEFAULT_OPEN_MODE | pyejdb.JBOTRUNC)
>>>
>>> parrot1 = {
... "name": "Grenny",
... "type": "African Grey",
... "male": True,
... "age": 1,
... "birthdate": datetime.utcnow(),
... "likes": ["green color", "night", "toys"],
... "extra1": None
... }
>>> parrot2 = {
... "name": "Bounty",
... "type": "Cockatoo",
... "male": False,
... "age": 15,
... "birthdate": datetime.utcnow(),
... "likes": ["sugar cane"],
... "extra1": None
... }
>>> ejdb.save("parrots2", parrot1, parrot2)
>>>
>>> with ejdb.find("parrots2", {"likes" : "toys"},
... hints={"$orderby" : [("name", 1)]}) as cur:
... print("found %s parrots" % len(cur))
... for p in cur:
... print("%s likes toys!" % p["name"])
...
found 1 parrots
Grenny likes toys!
>>> ejdb.close()
>>>
==================================================================
Python 3.5.0 (default, Sep 20 2015, 11:28:25)
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyejdb
>>> from datetime import datetime
>>>
>>> #Open database
... ejdb = pyejdb.EJDB("zoo", pyejdb.DEFAULT_OPEN_MODE | pyejdb.JBOTRUNC)
>>> with ejdb.find("parrots2", {"likes" : "toys"},
... hints={"$orderby" : [("name", 1)]}) as cur:
... print("found %s parrots" % len(cur))
... for p in cur:
... print("%s likes toys!" % p["name"])
...
found 0 parrots
libejdb 1.2.10
pyejdb 1.0.16
Python 3.5
Archlinux
Data has been saved to the database file, but it can not be read.
Well, the problem is in the file setup.py, the version check is comparing strings:
if py_ver < min_py_vers[int(py_ver[0])]:
raise SystemExit("Aborted: EJDB requires Python >= {0}".format(min_py_vers[int(py_ver[0])]))
In my case, "2.7.10" < "2.7.2" returns True, so the check does not pass and the SystemExit is raised.
building '_pyejdb' extension
creating build/temp.macosx-10.4-x86_64-2.7
creating build/temp.macosx-10.4-x86_64-2.7/src
/usr/local/bin/gcc-4.2 -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/Loki/.pyenv/versions/2.7.6/include/python2.7 -c src/pyejdb.c -o build/temp.macosx-10.4-x86_64-2.7/src/pyejdb.o -std=c99 -Wall
/usr/local/bin/gcc-4.2 -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib build/temp.macosx-10.4-x86_64-2.7/src/pyejdb.o -ltcejdb -lz -lpthread -lm -lc -lrt -o build/lib.macosx-10.4-x86_64-2.7/_pyejdb.so
ld: library not found for -lrt
collect2: ld returned 1 exit status
error: command '/usr/local/bin/gcc-4.2' failed with exit status 1
When I try to save some cyrillic text to my EJDB I get:
Traceback (most recent call last):
File "test11.py", line 9, in <module>
db.save('d', {'name': 'ПРОВЕРКА'})
File "/usr/local/lib/python2.7/dist-packages/pyejdb/__init__.py", line 257, in save
_oid = self.__ejdb.save(cname, bson.serialize_to_bytes(doc), **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyejdb/bson.py", line 819, in serialize_to_bytes
serialize_to_stream(document, stream)
File "/usr/local/lib/python2.7/dist-packages/pyejdb/bson.py", line 824, in serialize_to_stream
py_to_bs(document).serialize(stream)
File "/usr/local/lib/python2.7/dist-packages/pyejdb/bson.py", line 363, in serialize
v.serialize(e_list)
File "/usr/local/lib/python2.7/dist-packages/pyejdb/bson.py", line 240, in serialize
value_b = self._value.encode("utf-8")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 0: ordinal not in range(128)
is missing the 7056835 commit, which is critical for installing on mac os.
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.