Database

class pyArango.database.Database(connection, name)[source]

Databases are meant to be instanciated by connections

AQLQuery(query, batchSize=100, rawResults=False, bindVars=None, options=None, count=False, fullCount=False, json_encoder=None, **moreArgs)[source]

Set rawResults = True if you want the query to return dictionnaries instead of Document objects. You can use **moreArgs to pass more arguments supported by the api, such as ttl=60 (time to live)

createCollection(className='Collection', **colProperties)[source]

Creates a collection and returns it. ClassName the name of a class inheriting from Collection or Egdes, it can also be set to ‘Collection’ or ‘Edges’ in order to create untyped collections of documents or edges. Use colProperties to put things such as ‘waitForSync = True’ (see ArangoDB’s doc for a full list of possible arugments). If a ‘_properties’ dictionary is defined in the collection schema, arguments to this function overide it

createGraph(name, createCollections=True, isSmart=False, numberOfShards=None, smartGraphAttribute=None, replicationFactor=None, writeConcern=None)[source]

Creates a graph and returns it. ‘name’ must be the name of a class inheriting from Graph. Checks will be performed to make sure that every collection mentionned in the edges definition exist. Raises a ValueError in case of a non-existing collection.

dropAllCollections()[source]

drops all public collections (graphs included) from the database

explainAQLQuery(query, bindVars=None, allPlans=False)[source]

Returns an explanation of the query. Setting allPlans to True will result in ArangoDB returning all possible plans. False returns only the optimal plan

fetchDocument(_id)[source]

fetchs a document using it’s _id

fetch_element(aql_query, bind_vars=None, dont_raise_error_if_empty=False, default_output=None, logger=None, log_level=10)[source]

Fetch element by running a query.

aql_query : str
aql query string.
bind_vars : dict, optional
dictonary of bind variables (the default is None)
dont_raise_error_if_empty: bool, optional
do not raise error if the returned is empty. (the default is False)
default_output: dict, optional
default output if no value is returned. (the default is None)
logger : Logger, optional
logger to log the query and result. (the default is None means don’t log)
log_level: Logger.loglevel, optional
level of the log. (the default is logging.DEBUG)
AQLFetchError
When unable to fetch results or more than one 1 results returned.
any
an element returned by query.
fetch_list(aql_query, bind_vars=None, batch_size=200, dont_raise_error_if_empty=False, logger=None, log_level=10)[source]

Fetch list of elements by running a query and merging all the batches.

aql_query : str
aql query string.
bind_vars : dict, optional
dictonary of bind variables (the default is None)
batch_size : int, optional
fetching batch size (the default is 200)
dont_raise_error_if_empty: bool, optional
do not raise error if the returned is empty. (the default is False)
logger : Logger, optional
logger to log the query and result. (the default is None means don’t log)
log_level: Logger.loglevel, optional
level of the log. (the default is logging.DEBUG)
AQLFetchError
When unable to fetch results
list(any)
a list returned by query.
fetch_list_as_batches(aql_query, bind_vars=None, batch_size=200, dont_raise_error_if_empty=False, logger=None, log_level=10)[source]

Fetch list of elements as batches by running the query.

Generator which yeilds each batch as result.

aql_query : str
aql query string.
bind_vars : dict, optional
dictonary of bind variables (the default is None)
batch_size : int, optional
fetching batch size (the default is 200)
dont_raise_error_if_empty: bool, optional
do not raise error if the returned is empty. (the default is False)
logger : Logger, optional
logger to log the query and result. (the default is None means don’t log)
log_level: Logger.loglevel, optional
level of the log. (the default is logging.DEBUG)
AQLFetchError
When unable to fetch results
list(any)
a list returned by query.
hasCollection(name)[source]

returns true if the databse has a collection by the name of ‘name’

hasGraph(name)[source]

returns true if the databse has a graph by the name of ‘name’

no_fetch_run(aql_query, bind_vars=None, logger=None, log_level=10)[source]

Run query which doesn’t have a return.

aql_query : str
aql query string.
bind_vars : dict, optional
dictonary of bind variables (the default is None)
logger : Logger, optional
logger to log the query and result. (the default is None means don’t log)
log_level: Logger.loglevel, optional
level of the log. (the default is logging.DEBUG)
AQLFetchError
When able to fetch results.
reload()[source]

reloads collections and graphs

reloadCollections()[source]

reloads the collection list.

reloadGraphs()[source]

reloads the graph list

transaction(collections, action, waitForSync=False, lockTimeout=None, params=None)[source]

Execute a server-side transaction

validateAQLQuery(query, bindVars=None, options=None)[source]

returns the server answer is the query is valid. Raises an AQLQueryError if not

class pyArango.database.DBHandle(connection, name)[source]

As the loading of a Database also triggers the loading of collections and graphs within. Only handles are loaded first. The full database are loaded on demand in a fully transparent manner.