Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The official ArangoDB Python driver.

License

NotificationsYou must be signed in to change notification settings

arangodb/python-arango

Repository files navigation

Logo

CircleCICodeQLDocsCoverage StatusLast commit

PyPI version badgePython versions badge

LicenseCode style: blackDownloads

Python-Arango

Python driver forArangoDB, a scalable multi-modeldatabase natively supporting documents, graphs and search.

If you're interested in using asyncio, please checkpython-arango-async.

Requirements

  • ArangoDB version 3.11+
  • Python version 3.9+

Installation

pip install python-arango --upgrade

Getting Started

Here is a simple usage example:

fromarangoimportArangoClient# Initialize the client for ArangoDB.client=ArangoClient(hosts="http://localhost:8529")# Connect to "_system" database as root user.sys_db=client.db("_system",username="root",password="passwd")# Create a new database named "test".sys_db.create_database("test")# Connect to "test" database as root user.db=client.db("test",username="root",password="passwd")# Create a new collection named "students".students=db.create_collection("students")# Add a persistent index to the collection.students.add_index({'type':'persistent','fields': ['name'],'unique':True})# Insert new documents into the collection.students.insert({"name":"jane","age":39})students.insert({"name":"josh","age":18})students.insert({"name":"judy","age":21})# Execute an AQL query and iterate through the result cursor.cursor=db.aql.execute("FOR doc IN students RETURN doc")student_names= [document["name"]fordocumentincursor]

Another example withgraphs:

fromarangoimportArangoClient# Initialize the client for ArangoDB.client=ArangoClient(hosts="http://localhost:8529")# Connect to "test" database as root user.db=client.db("test",username="root",password="passwd")# Create a new graph named "school".graph=db.create_graph("school")# Create a new EnterpriseGraph [Enterprise Edition]eegraph=db.create_graph(name="school",smart=True)# Create vertex collections for the graph.students=graph.create_vertex_collection("students")lectures=graph.create_vertex_collection("lectures")# Create an edge definition (relation) for the graph.edges=graph.create_edge_definition(edge_collection="register",from_vertex_collections=["students"],to_vertex_collections=["lectures"])# Insert vertex documents into "students" (from) vertex collection.students.insert({"_key":"01","full_name":"Anna Smith"})students.insert({"_key":"02","full_name":"Jake Clark"})students.insert({"_key":"03","full_name":"Lisa Jones"})# Insert vertex documents into "lectures" (to) vertex collection.lectures.insert({"_key":"MAT101","title":"Calculus"})lectures.insert({"_key":"STA101","title":"Statistics"})lectures.insert({"_key":"CSC101","title":"Algorithms"})# Insert edge documents into "register" edge collection.edges.insert({"_from":"students/01","_to":"lectures/MAT101"})edges.insert({"_from":"students/01","_to":"lectures/STA101"})edges.insert({"_from":"students/01","_to":"lectures/CSC101"})edges.insert({"_from":"students/02","_to":"lectures/MAT101"})edges.insert({"_from":"students/02","_to":"lectures/STA101"})edges.insert({"_from":"students/03","_to":"lectures/CSC101"})# Traverse the graph in outbound direction, breath-first.query="""    FOR v, e, p IN 1..3 OUTBOUND 'students/01' GRAPH 'school'    OPTIONS { bfs: true, uniqueVertices: 'global' }    RETURN {vertex: v, edge: e, path: p}    """cursor=db.aql.execute(query)

Please see thedocumentation for more details.

About

The official ArangoDB Python driver.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors32


[8]ページ先頭

©2009-2025 Movatter.jp