4.0.0
New Features
-
Manage documents using IDs (more examples here):
col.get('foo/bar') # Get by document ID col.get('bar') # Get by document key col.get({'_id': 'foo/bar'}) # Get by document body with ID col.get({'_key': 'bar'}) # Get by document body with key col.update({'_id': 'foo/bar', 'val': 1}) # Update by document ID col.update({'_key': 'bar', 'val': 1}) # Update by document key col.replace({'_id': 'foo/bar', 'val': 2}) # Replace by document ID col.replace({'_key': 'bar', 'val': 2}) # Replace by document key col.delete('foo/bar') # Delete by document ID col.delete('bar') # Delete by document key col.delete({'_id': 'foo/bar'}) # Delete by document body with ID col.delete({'_key': 'bar'}) # Delete by document body with key
-
Perform basic document operations directly from
Database(more examples here):db.insert_document('students', {'_key': 'dave'}) db.has_document('students/dave') db.document('students/dave') db.update_document({'_id': 'students/dave', 'val': 1}) db.replace_document({'_id': 'students/dave', 'val': 2}) db.delete_document('students/dave')
-
Manage vertices and edges directly from
Graph(more examples here):graph.insert_vertex('profs', {'_key': 'jon', 'name': 'Jon'}) graph.update_vertex({'_id': 'profs/jon', 'age': 35}) graph.replace_vertex({'_id': 'profs/jon', 'name': 'Jon', 'age':36}) graph.has_vertex('profs/jon') graph.vertex('profs/jon') graph.delete_vertex('profs/jon') graph.insert_edge('teach', {'_id': 'teach/1', '_from': 'profs/jon', '_to': 'lectures/CS101'}) graph.replace_edge({'_id': 'teach/1', '_from': 'profs/jon', '_to': 'lectures/CS101'}) graph.update_edge({'_id': 'teach/1', 'online': True}) graph.has_edge('teach/1') graph.edge('teach/1') graph.delete_edge('teach/1') graph.link('teach', 'profs/jon', 'lectures/CS101') graph.edges('teach', 'profs/jon', direction='out')
-
Executing a transaction now returns
TransactionJobobjects, allowing result retrieval after commit (see examples, restrictions and caveats here):with db.begin_transaction() as txn_db: txn_col = txn_db.collection('students') job1 = txn_col.insert({'_key': 'Abby'}) job2 = txn_col.insert({'_key': 'John'}) job3 = txn_col.insert({'_key': 'Mary'}) assert job1.result()['_id'] == 'students/Abby' assert job2.result()['_id'] == 'students/John' assert job3.result()['_id'] == 'students/Mary'
-
Added new methods to
Cursor. MethodsCursor.popandCursor.fetchlets you control when new batches are fetched from server. See here for details. -
Added new methods to
AQL. See here for details. -
Added new methods to
Graph. See here for details. -
Added new methods to
EdgeCollection. See here for details. -
Added new method
Database.ping. See here for details. -
Added support for Foxx. See here for details.
-
Improved error handling: the catch-all exception
ArangoErrornow splits further intoArangoClientErrorandArangoServerErrror, allowing you to differentiate errors coming from server vs. client. Server exceptions, furthermore, give you access to HTTP request response metadata (e.g. status code, payload, headers). See here for details.
Non-Backward Compatible Changes
Unfortunately, many updates in 4.0.0 are not backward compatible. If you are upgrading, you will need to change your code in several places (sorry for the inconvenience).
High Level Changes
-
Some APIs were rather awkward and didn't make sense. For example,
ArangoClientasks you for username and password before you specify the database. The initialization and the usage ofArangoClientwere made simpler and more intuitive. See here for examples. -
In previous versions of python-arango, attempt to abstract away ArangoDB's
_systemdatabase did more harm than good. One example is the duplicated set of admin methods inArangoClientandDatabase. These admin methods are now accessible fromDatabaseonly, and you must connect to_systemdatabase explicitly. See here for examples. -
Some method names and signatures were modified for consistency. This is less likely to break your code if you were using keyword arguments over positional ones. Some examples are document management methods such as update, replace and delete. You should carry out a comprehensive review of all methods used in your code with new API specification.
-
Some modules were moved and/or renamed. Imports other than
from arango import ArangoClientandfrom arango.exceptions import *may not work anymore. Python-arango was designed such that the two imports are all you need for complete feature access. -
Some classes were renamed (e.g.
DatabasetoStandardDatabase,CollectiontoStandardCollection). As long as you are not importing classes directly, this change alone should not break your code. Note thatStandardDatabaseandStandardCollectionare still referred to asDatabaseandCollectionin this changelog.
Databases
- User and access/permission management in python-arango was poorly designed (perhaps "broken" is the better word). It has been completely overhauled with new set of methods. Old methods such as
Database.grant_user_accessandDatabase.grant_revoke_accesswere removed. See here for details. - Removed parameter
userin methodDatabase.databases(redundant). - Removed method
Database.sleep(not supported by ArangoDB anymore). - Removed method
Database.execute(not supported by ArangoDB anymore). - Removed parameter
names_onlyin methodsDatabase.collections,Database.graphsandDatabase.users(redundant).
Async Execution, Batch Execution and Transactions
- Renamed method
Database.asynctoDatabase.begin_async_execution. While rest of the API for async execution remains more or less the same, underlying class structures were overhauled. See here for details. - Renamed method
Database.batchtoDatabase.begin_batch_execution. While rest of the API for batch execution remains more or less the same, underlying class structures were overhauled. See here for details. - Renamed method
Database.transactiontoDatabase.begin_transaction. While rest of the API for transactions remains more or less the same, underlying class structures were overhauled. See here for details. - Removed parameter
commit_on_errorand methodclearfrom batch execution and transactions. - Multiple commits using the same batch execution or transaction objects are not allowed anymore.
- Removed parameter
raise_errorsin methodsAsyncJob.resultandBatchJob.result. Job exceptions are now always raised.
Collections and Documents
- All document revisions are now checked by default. In other words, all
check_revparameters in document management methods default toTrue. - Method
Collection.unloadnow returns a boolean. - Method
Collection.loadnow returns a boolean. - Method
Collection.renamenow returns a boolean. - Method
Collection.truncatenow returns a boolean. - Method
Collection.checksumnow returns a string. - Removed parameter
inclusivein methodCollection.find_in_range. Now it is always inclusive on both ends. - Renamed parameter
offsettoskipin methodCollection.find. - Renamed parameter
offsettoskipin methodCollection.find_in_range. - Parameter
limitnow defaults to100in methodsCollection.find,Collection.find_near,Collection.find_in_range,Collection.find_in_boxandCollection.find_by_text.
Graphs
-
Changed the signature of method
Graph.create_edge_definition, and edge definitions in general (see here for details):# old { 'name': 'teach', 'from_collections': ['teachers'], 'to_collections': ['lectures'] } # new { 'edge_collection': 'teach', 'from_vertex_collections': ['teachers'], 'to_vertex_collections': ['lectures'] }
-
Removed method
Graph.orphan_collections. UseGraph.edge_definitionsinstead.
Cursors
- Removed
arango.cursor.ExportCursor. All cursors are now instances ofarango.cursor.Cursor.
Pregel
- Refactored Pregel API. See here for new usage examples.
HTTP Client
- Simplified the way custom HTTP clients are defined. See here for details.
Error Handling
- Removed exception
arango.exceptions.CollectionBadStatusError. - Removed exception
arango.exceptions.ServerSleepError. - Removed exception
arango.exceptions.UserAccessError. - Removed exception
arango.exceptions.UserGrantAccessError. - Removed exception
arango.exceptions.UserRevokeAccessError. - Removed exception
arango.exceptions.ClusterTestError. - Removed exception
arango.exceptions.GraphGetError. - Removed exception
arango.exceptions.OrphanCollectionListError. - Renamed exception
arango.exceptions.TransactionErrortoarango.exceptions.TransactionExecuteError. - All
ignore_missingparameters now default to False.
Logging
- Removed python-arango's internal logger (redundant). You can instead increase the verbosity of requests logger, or inject your own logger using a custom HTTP client. See here for examples.