@@ -24,32 +24,32 @@ Installation
24
24
25
25
- Stable
26
26
27
- ~~~~ {.sourceCode . bash}
27
+ ``` bash
28
28
sudo pip install py-arango
29
- ~~~~
29
+ ```
30
30
31
31
- Latest
32
32
33
- ~~~~ {.sourceCode . bash}
33
+ ``` bash
34
34
git clone https://github.com/Joowani/py-arango.git
35
35
cd py-arango
36
36
python2.7 setup.py install
37
- ~~~~
37
+ ```
38
38
39
39
Initializing Connection
40
40
-----------------------
41
41
42
- ~~~~ {.sourceCode . python}
42
+ ``` python
43
43
from arango import Arango
44
44
45
45
# Initialize ArangoDB connection
46
46
a = Arango(host = " localhost" , port = 8529 )
47
- ~~~~
47
+ ```
48
48
49
49
Databases
50
50
---------
51
51
52
- ~~~~ {.sourceCode . python}
52
+ ``` python
53
53
# List the database names
54
54
a.databases
55
55
a.databases[" user" ]
@@ -83,12 +83,12 @@ a.{whatever}
83
83
a.db(" my_db" ).add_collection(" my_col" )
84
84
a.db(" my_db" ).col(" my_col" ).add_document({" value" : 1 })
85
85
a.db(" my_db" ).{whatever}
86
- ~~~~
86
+ ```
87
87
88
88
AQL Functions
89
89
-------------
90
90
91
- ~~~~ {.sourceCode . python}
91
+ ``` python
92
92
my_db = a.db(" my_db" )
93
93
94
94
# List the AQL functions defined in database "my_db"
@@ -102,12 +102,12 @@ my_db.add_aql_function(
102
102
103
103
# Remove an AQL function
104
104
my_db.remove_aql_function(" myfunctions::temperature::ctof" )
105
- ~~~~
105
+ ```
106
106
107
107
AQL Queries
108
108
-----------
109
109
110
- ~~~~ {.sourceCode . python}
110
+ ``` python
111
111
# Retrieve the execution plan without actually executing it
112
112
my_db.explain_query(" FOR doc IN my_col RETURN doc" )
113
113
@@ -121,12 +121,12 @@ cursor = my_db.execute_query(
121
121
)
122
122
for doc in cursor: # the cursor is deleted when the generator is exhausted
123
123
print doc
124
- ~~~~
124
+ ```
125
125
126
126
Collections
127
127
-----------
128
128
129
- ~~~~ {.sourceCode . python}
129
+ ``` python
130
130
my_db = a.db(" my_db" )
131
131
132
132
# List the collection names in "my_db"
@@ -184,12 +184,12 @@ my_col.truncate()
184
184
# Check if a document exists in the collection
185
185
my_col.contains(" a_document_key" )
186
186
" a_document_key" in my_col
187
- ~~~~
187
+ ```
188
188
189
189
Indexes
190
190
-------
191
191
192
- ~~~~ {.sourceCode . python}
192
+ ``` python
193
193
my_col = a.collection(" my_col" ) # or a.col("mycol")
194
194
195
195
# List the indexes in collection "my_col"
@@ -210,12 +210,12 @@ my_col.add_geo_index(fields=["longitude", "latitude"])
210
210
211
211
# Add a fulltext index on attribute "attr1"
212
212
my_col.add_fulltext_index(fields = [" attr1" ], min_length = 10 )
213
- ~~~~
213
+ ```
214
214
215
215
Documents
216
216
---------
217
217
218
- ~~~~ {.sourceCode . python}
218
+ ``` python
219
219
my_col = a.db(" my_db" ).collection(" my_col" )
220
220
221
221
# Retrieve a document by its key
@@ -237,12 +237,12 @@ my_col.remove_document("doc01")
237
237
for doc in my_col:
238
238
new_value = doc[" value" ] + 1
239
239
my_col.update_document(doc[" _key" ], {" new_value" : new_value})
240
- ~~~~
240
+ ```
241
241
242
242
Simple Queries (Collection-Specific)
243
243
------------------------------------
244
244
245
- ~~~~ {.sourceCode . python}
245
+ ``` python
246
246
# Return the first 5 documents in collection "my_col"
247
247
my_col.first(5 )
248
248
@@ -272,12 +272,12 @@ my_col.within(latitude=100, longitude=20, radius=15)
272
272
273
273
# Return all documents near a given coordinate (requires geo-index)
274
274
my_col.near(latitude = 100 , longitude = 20 )
275
- ~~~~
275
+ ```
276
276
277
277
Graphs
278
278
------
279
279
280
- ~~~~ {.sourceCode . python}
280
+ ``` python
281
281
my_db = a.db(" my_db" )
282
282
283
283
# List all the graphs in the database
@@ -307,12 +307,12 @@ my_graph.revision
307
307
my_graph.edge_definitions
308
308
my_graph.vertex_collections
309
309
my_graph.orphan_collections
310
- ~~~~
310
+ ```
311
311
312
312
Vertices
313
313
--------
314
314
315
- ~~~~ {.sourceCode . python}
315
+ ``` python
316
316
# Add new vertices (again if "_key" is not given it's auto-generated)
317
317
my_graph.add_vertex(" vcol01" , {" _key" : " v01" , " value" : 1 })
318
318
my_graph.add_vertex(" vcol02" , {" _key" : " v01" , " value" : 1 })
@@ -325,12 +325,12 @@ my_graph.update_vertex("vol02/v01", {"new_value": 3})
325
325
326
326
# Remove a vertex
327
327
my_graph.remove_vertex(" vol01/v01" )
328
- ~~~~
328
+ ```
329
329
330
330
Edges
331
331
-----
332
332
333
- ~~~~ {.sourceCode . python}
333
+ ``` python
334
334
# Add a new edge
335
335
my_graph.add_edge(
336
336
" ecol01" , # edge collection name
@@ -351,12 +351,12 @@ my_graph.update_edge("ecol01/e01", {"foo": 3})
351
351
352
352
# Remove an edge
353
353
my_graph.remove_edge(" ecol01/e01" )
354
- ~~~~
354
+ ```
355
355
356
356
Graph Traversals
357
357
----------------
358
358
359
- ~~~~ {.sourceCode . python}
359
+ ``` python
360
360
my_graph = a.db(" my_db" ).graph(" my_graph" )
361
361
362
362
# Execute a graph traversal
@@ -371,12 +371,12 @@ results.get("visited")
371
371
372
372
# Return the paths traversed in order
373
373
results.get(" paths" )
374
- ~~~~
374
+ ```
375
375
376
376
Batch Requests
377
377
--------------
378
378
379
- ~~~~ {.sourceCode . python}
379
+ ``` python
380
380
# NOTE : only (add/update/replace/remove) methods for (documents/vertices/edges) are supported at the moment
381
381
382
382
# Execute a batch request for managing documents
@@ -426,12 +426,12 @@ self.db.execute_batch([
426
426
{" wait_for_sync" : True }
427
427
),
428
428
])
429
- ~~~~
429
+ ```
430
430
431
431
Transactions
432
432
------------
433
433
434
- ~~~~ {.sourceCode . python}
434
+ ``` python
435
435
# Execute a transaction
436
436
action = """
437
437
function () {
@@ -448,7 +448,7 @@ res = my_db.execute_transaction(
448
448
wait_for_sync = True ,
449
449
lock_timeout = 10000
450
450
)
451
- ~~~~
451
+ ```
452
452
453
453
To Do
454
454
-----
@@ -465,6 +465,6 @@ To Do
465
465
Running Tests (requires ArangoDB on localhost)
466
466
----------------------------------------------
467
467
468
- ~~~~ {.sourceCode . bash}
468
+ ``` bash
469
469
nosetests
470
- ~~~~
470
+ ```
0 commit comments