saeschdivara / arangopy Goto Github PK
View Code? Open in Web Editor NEWPython driver Framework to access https://github.com/triAGENS/ArangoDB
License: MIT License
Python driver Framework to access https://github.com/triAGENS/ArangoDB
License: MIT License
When calling Model.objects.get_or_create(foo='bar'), it would be nice to get the instance as first element of the return and a Boolean as the second.
The Boolean simply says False, when the Item already exists and True when it has to be created. Or the other way around, whatever is more intuitive.
def something():
item, item_new = Model.objects.get_or_create(foo='bar')
if item_new:
item.save()
This we really need
When calling Model.objects.get_or_create(other_model=reference_model) and saving the Model by Model.save() a "not JSON serializable" error will be raised.
reference_model = ReferenceModel.objects.get(foo='bar')
model, model_new = Model.objects.get_or_create(reference=reference_model)
if model_new:
model.save()
raises this error
TypeError: <app.models.ReferenceModel object at 0x106b05b50> is not JSON serializable
When calling Model.objects.get_or_create(foo='bar') I get an empty object back. After a save, the query parameters were set as null in the database, when I do not apply them again.
Possibility to set the parameters used for the query by default, without setting them again before saving the object?
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from app.models import Model
>>> model_instance = Model.objects.get_or_create(name='test001')
>>> print model_instance.name
None
>>> model_instance.save()
>>> print model_instance.name
None
Through table for ManyToMany field (own table which can have data)
When filtering a document on a TextField or CharField returns no object. In this case i json.dumps a JSON and save this in a TextField.
When i look at the document in the AdminInterface of arangodb, the string seems to be encapsulated. Doing a filter-query on that string seems to return no result.
>>> from app.models import Model, ReferenceModel
>>> r = ReferenceModel.objects.all()[:1]
>>> r = r[0]
>>> r
<app.models.ReferenceModel object at 0x10f7ee5d0>
>>> m = Model()
>>> m.reference_model = r
>>> m.save()
>>> m.property = '[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]'
>>> m.save()
>>> m.property
[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]
>>> list = Model.objects.filter(property='[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]')
>>> list
<arangodb.orm.models.CollectionQueryset object at 0x10f808f50>
>>> list[0]
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/orm/models.py", line 39, in __getitem__
self._generate_cache()
File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/orm/models.py", line 325, in _generate_cache
result = self._query.execute()
File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/query/advanced.py", line 234, in execute
result = Query.execute_raw(query_string=query_data)
File "/Users/xxx/PycharmProjects/xxx/website/env/lib/python2.7/site-packages/arangodb/query/advanced.py", line 83, in execute_raw
raise err
HttpClientError: Client Error 400: http://localhost:8083/_db/test_db1/_api/cursor
When I check the arangadb document properties i see that the saved string has been encapsulated.
[{"displayMode": 3, "values": [["3.5", 0]], "name": "Lasts %0 Seconds"}, {"displayMode": 3, "values": [["30", 0], ["60", 0]], "name": "Consumes %0 of %1 Charges on use"}, {"displayMode": 3, "values": [["60", 0]], "name": "Currently has %0 Charges"}, {"displayMode": 0, "values": [["+35% to Chaos Resistance", 1]], "name": ""}]
In arangodb there is no option to create bidirectional edge. However two directed edges can be created. When using CollectionModel
and ForeignKeyField
we specify one column (_from
or _to
) to be foreign key to another single table only. So there is no way to create a bidirectional edge.
Please give a method or automatic escape the input values for the aql string
I will start migrating my code, hopefully I won't have to break the compatibility with the old versions
Can you please update https://github.com/saeschdivara/ArangoPy/blob/master/README.md#supported-versions ?
Ideally keeping only the versions that have not reached EOL: https://www.arangodb.com/eol-notice/
What if you're connecting to multiple ArangoDB clusters?
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.