Magics¶
Magics are configurable with the following:
# !pip install arangoml[notebook]
%load_ext arangoml
arangoml = %enable_arangoml
- class arangoml.magic.ArangoMLMagics(**kwargs: Any)¶
IPython Magic commands for ArangoML
- property system_db: StandardDatabase¶
Returns the system database.
- property db: StandardDatabase¶
Returns the current database.
- property collection: StandardCollection¶
Returns the current collection.
- property graph: Graph¶
Returns the current graph.
- enable_arangoml(line: Any) ArangoML ¶
Returns an ArangoML instance.
- Assumes that the following environment variables are set:
ARANGODB_HOSTS
ARANGODB_USER (_system access)
ARANGODB_PW (_system access)
ARANGODB_USER_TOKEN (optional, _system access)
ARANGODB_CA_CERT_FILE (optional)
PROJECTS_ENDPOINT
TRAINING_ENDPOINT
PREDICTION_ENDPOINT
- Returns:
An ArangoML instance.
- Return type:
arangoml.ArangoML
- createDatabase(line: str) bool ¶
Create a new database.
- Parameters:
line (str) – The name of the database to create.
- Returns:
Whether the database was created or not.
- Return type:
bool
- deleteDatabase(line: str) bool ¶
Delete a database.
- Parameters:
line (str) – The name of the database to delete.
- Returns:
Whether the database was deleted or not.
- Return type:
bool
- listDatabases(line: str) list[str] ¶
List all databases.
- Returns:
A list of all databases.
- Return type:
list[str]
- useDatabase(line: str) StandardDatabase | None ¶
Set the current database.
- Parameters:
line (str) – The name of the database to select.
- Returns:
The selected database instance, if it exists.
- Return type:
arango.database.StandardDatabase | None
- getDatabase(line: str) StandardDatabase | None ¶
Get a database without setting it as the current database.
- Parameters:
line (str) – The name of the database to get.
- Returns:
The selected database instance, if it exists.
- Return type:
arango.database.StandardDatabase | None
- whichDatabase(line: str) StandardDatabase ¶
Return the currently selected database.
- Returns:
The currently selected database.
- Return type:
arango.database.StandardDatabase
- listCollections(line: str) list[str] ¶
List all collections.
- Returns:
A list of all collections.
- Return type:
list[str]
- createVertexCollection(line: str) bool ¶
Create a Vertex Collection.
- Parameters:
line (str) – The name of the vertex collection to create.
- Returns:
Whether the collection was created or not.
- Return type:
bool
- createEdgeCollection(line: str) bool ¶
Create an Edge Collection.
- Parameters:
line (str) – The name of the edge collection to create.
- Returns:
Whether the edge collection was created or not.
- Return type:
bool
- truncateCollection(line: str) bool ¶
Truncate a collection.
- Parameters:
line (str) – The name of the collection to truncate.
- Returns:
Whether the collection was truncated or not.
- Return type:
bool
- deleteCollection(line: str) bool ¶
Delete a collection.
- Parameters:
line (str) – The name of the collection to delete.
- Returns:
Whether the collection was deleted or not.
- Return type:
bool
- useCollection(line: str) StandardCollection | None ¶
Set the current collection.
- Parameters:
line (str) – The name of the collection to select.
- Returns:
The selected collection instance, if it exists.
- Return type:
arango.collection.Collection | None
- getCollection(line: str) StandardCollection | None ¶
Get a collection without setting it as the current collection.
- Parameters:
line (str) – The name of the collection to get.
- Returns:
The selected collection instance, if it exists.
- Return type:
arango.collection.Collection | None
- whichCollection(line: str) StandardCollection ¶
Return the currently selected collection.
- Returns:
The currently selected collection.
- Return type:
arango.collection.Collection
- sampleCollection(line: str) dict[str, Any] | None ¶
Return a sample of the currently selected collection.
- Returns:
A sample of the currently selected collection.
- Return type:
arango.collection.Collection
- insertDocument(line: dict[str, Any] | str) bool ¶
Insert a document into a collection.
- Parameters:
line (str) – The document to insert.
- Returns:
Whether the document was inserted or not.
- Return type:
bool
- replaceDocument(line: dict[str, Any] | str) bool ¶
Replace a document in a collection.
- Parameters:
line (str | dict[str, Any]) – The document to replace. Must contain a ‘_key’ or ‘_id’ field.
- Returns:
Whether the document was replaced or not.
- Return type:
bool
- updateDocument(line: dict[str, Any] | str) bool ¶
Update a document in a collection.
- Parameters:
line (str | dict[str, Any]) – The document to update. Must contain a ‘_key’ or ‘_id’ field.
- Returns:
Whether the document was updated or not.
- Return type:
bool
- deleteDocument(line: dict[str, Any] | str) bool ¶
Delete a document from a collection.
- Parameters:
line (str | dict[str, Any]) – The document to delete.
- Returns:
Whether the document was deleted or not.
- Return type:
bool
- getDocument(line: dict[str, Any] | str) dict[str, Any] | None ¶
Get a document from a collection.
- Parameters:
line (str | dict[str, Any]) – The document to get.
- Returns:
The document, if it exists.
- Return type:
dict[str, Any] | None
- importBulk(line: str, cell: str | None = None) dict[str, Any] | list[dict[str, Any]] ¶
Import documents into a collection.
- Parameters:
line (str) – The documents to import.
cell (Optional[str]) – The documents to import in multi-line format.
- Returns:
The result of the import operation.
- createGraph(line: str) bool ¶
Create a graph.
- Parameters:
line (str) – The name of the graph to create.
- Returns:
Whether the graph was created or not.
- Return type:
bool
- deleteGraph(line: str) bool ¶
Delete a graph.
- Parameters:
line (str) – The name of the graph to delete.
- Returns:
Whether the graph was deleted or not.
- Return type:
bool
- createEdgeDefinition(line: str | dict[str, Any]) bool ¶
Create an edge definition.
- Parameters:
line (str) – The name of the edge definition to create.
- Returns:
Whether the edge definition was created or not.
- Return type:
bool
- listGraphs(line: str) list[str] ¶
List all graphs.
- Returns:
A list of all graphs.
- Return type:
list[str]
- useGraph(line: str) Graph | None ¶
Set the current Graph.
- Parameters:
line (str) – The name of the graph to select.
- Returns:
The selected graph instance, if it exists.
- Return type:
arango.graph.Graph | None
- getGraph(line: str) Graph | None ¶
Get a graph without setting it as the current graph.
- Parameters:
line (str) – The name of the graph to get.
- Returns:
The selected graph instance, if it exists.
- Return type:
arango.graph.Graph | None
- whichGraph(line: str) Graph ¶
Return the currently selected graph.
- Returns:
The currently selected graph.
- Return type:
arango.graph.Graph
- aql(line: str, cell: str | None = None) list[dict[str, Any]] ¶
Run an AQL query.
- Parameters:
line (str) – The AQL query to run.
cell (Optional[str]) – The AQL query to run in multi-line format.
- Returns:
The result of the AQL query.