@@ -24,32 +24,32 @@ Installation
2424
2525- Stable
2626
27- ~~~~ {.sourceCode . bash}
27+ ``` bash
2828sudo pip install py-arango
29- ~~~~
29+ ```
3030
3131- Latest
3232
33- ~~~~ {.sourceCode . bash}
33+ ``` bash
3434git clone https://github.com/Joowani/py-arango.git
3535cd py-arango
3636python2.7 setup.py install
37- ~~~~
37+ ```
3838
3939Initializing Connection
4040-----------------------
4141
42- ~~~~ {.sourceCode . python}
42+ ``` python
4343from arango import Arango
4444
4545# Initialize ArangoDB connection
4646a = Arango(host = " localhost" , port = 8529 )
47- ~~~~
47+ ```
4848
4949Databases
5050---------
5151
52- ~~~~ {.sourceCode . python}
52+ ``` python
5353# List the database names
5454a.databases
5555a.databases[" user" ]
@@ -83,12 +83,12 @@ a.{whatever}
8383a.db(" my_db" ).add_collection(" my_col" )
8484a.db(" my_db" ).col(" my_col" ).add_document({" value" : 1 })
8585a.db(" my_db" ).{whatever}
86- ~~~~
86+ ```
8787
8888AQL Functions
8989-------------
9090
91- ~~~~ {.sourceCode . python}
91+ ``` python
9292my_db = a.db(" my_db" )
9393
9494# List the AQL functions defined in database "my_db"
@@ -102,12 +102,12 @@ my_db.add_aql_function(
102102
103103# Remove an AQL function
104104my_db.remove_aql_function(" myfunctions::temperature::ctof" )
105- ~~~~
105+ ```
106106
107107AQL Queries
108108-----------
109109
110- ~~~~ {.sourceCode . python}
110+ ``` python
111111# Retrieve the execution plan without actually executing it
112112my_db.explain_query(" FOR doc IN my_col RETURN doc" )
113113
@@ -121,12 +121,12 @@ cursor = my_db.execute_query(
121121)
122122for doc in cursor: # the cursor is deleted when the generator is exhausted
123123 print doc
124- ~~~~
124+ ```
125125
126126Collections
127127-----------
128128
129- ~~~~ {.sourceCode . python}
129+ ``` python
130130my_db = a.db(" my_db" )
131131
132132# List the collection names in "my_db"
@@ -184,12 +184,12 @@ my_col.truncate()
184184# Check if a document exists in the collection
185185my_col.contains(" a_document_key" )
186186" a_document_key" in my_col
187- ~~~~
187+ ```
188188
189189Indexes
190190-------
191191
192- ~~~~ {.sourceCode . python}
192+ ``` python
193193my_col = a.collection(" my_col" ) # or a.col("mycol")
194194
195195# List the indexes in collection "my_col"
@@ -210,12 +210,12 @@ my_col.add_geo_index(fields=["longitude", "latitude"])
210210
211211# Add a fulltext index on attribute "attr1"
212212my_col.add_fulltext_index(fields = [" attr1" ], min_length = 10 )
213- ~~~~
213+ ```
214214
215215Documents
216216---------
217217
218- ~~~~ {.sourceCode . python}
218+ ``` python
219219my_col = a.db(" my_db" ).collection(" my_col" )
220220
221221# Retrieve a document by its key
@@ -237,12 +237,12 @@ my_col.remove_document("doc01")
237237for doc in my_col:
238238 new_value = doc[" value" ] + 1
239239 my_col.update_document(doc[" _key" ], {" new_value" : new_value})
240- ~~~~
240+ ```
241241
242242Simple Queries (Collection-Specific)
243243------------------------------------
244244
245- ~~~~ {.sourceCode . python}
245+ ``` python
246246# Return the first 5 documents in collection "my_col"
247247my_col.first(5 )
248248
@@ -272,12 +272,12 @@ my_col.within(latitude=100, longitude=20, radius=15)
272272
273273# Return all documents near a given coordinate (requires geo-index)
274274my_col.near(latitude = 100 , longitude = 20 )
275- ~~~~
275+ ```
276276
277277Graphs
278278------
279279
280- ~~~~ {.sourceCode . python}
280+ ``` python
281281my_db = a.db(" my_db" )
282282
283283# List all the graphs in the database
@@ -307,12 +307,12 @@ my_graph.revision
307307my_graph.edge_definitions
308308my_graph.vertex_collections
309309my_graph.orphan_collections
310- ~~~~
310+ ```
311311
312312Vertices
313313--------
314314
315- ~~~~ {.sourceCode . python}
315+ ``` python
316316# Add new vertices (again if "_key" is not given it's auto-generated)
317317my_graph.add_vertex(" vcol01" , {" _key" : " v01" , " value" : 1 })
318318my_graph.add_vertex(" vcol02" , {" _key" : " v01" , " value" : 1 })
@@ -325,12 +325,12 @@ my_graph.update_vertex("vol02/v01", {"new_value": 3})
325325
326326# Remove a vertex
327327my_graph.remove_vertex(" vol01/v01" )
328- ~~~~
328+ ```
329329
330330Edges
331331-----
332332
333- ~~~~ {.sourceCode . python}
333+ ``` python
334334# Add a new edge
335335my_graph.add_edge(
336336 " ecol01" , # edge collection name
@@ -351,12 +351,12 @@ my_graph.update_edge("ecol01/e01", {"foo": 3})
351351
352352# Remove an edge
353353my_graph.remove_edge(" ecol01/e01" )
354- ~~~~
354+ ```
355355
356356Graph Traversals
357357----------------
358358
359- ~~~~ {.sourceCode . python}
359+ ``` python
360360my_graph = a.db(" my_db" ).graph(" my_graph" )
361361
362362# Execute a graph traversal
@@ -371,12 +371,12 @@ results.get("visited")
371371
372372# Return the paths traversed in order
373373results.get(" paths" )
374- ~~~~
374+ ```
375375
376376Batch Requests
377377--------------
378378
379- ~~~~ {.sourceCode . python}
379+ ``` python
380380# NOTE : only (add/update/replace/remove) methods for (documents/vertices/edges) are supported at the moment
381381
382382# Execute a batch request for managing documents
@@ -426,12 +426,12 @@ self.db.execute_batch([
426426 {" wait_for_sync" : True }
427427 ),
428428])
429- ~~~~
429+ ```
430430
431431Transactions
432432------------
433433
434- ~~~~ {.sourceCode . python}
434+ ``` python
435435# Execute a transaction
436436action = """
437437 function () {
@@ -448,7 +448,7 @@ res = my_db.execute_transaction(
448448 wait_for_sync = True ,
449449 lock_timeout = 10000
450450)
451- ~~~~
451+ ```
452452
453453To Do
454454-----
@@ -465,6 +465,6 @@ To Do
465465Running Tests (requires ArangoDB on localhost)
466466----------------------------------------------
467467
468- ~~~~ {.sourceCode . bash}
468+ ``` bash
469469nosetests
470- ~~~~
470+ ```
0 commit comments