{"id":2239,"library":"python-arango","title":"Python Driver for ArangoDB","description":"Python-Arango is the official Python driver for ArangoDB, a scalable multi-model database that natively supports documents, graphs, and key-values. It provides a comprehensive API for interacting with ArangoDB, including managing databases, collections, documents, graphs, and executing AQL queries. The library is actively maintained with regular releases, currently at version 8.3.1.","status":"active","version":"8.3.1","language":"python","source_language":"en","source_url":"https://github.com/arangodb/python-arango","tags":["arangodb","database","nosql","driver","document-database","graph-database"],"install":[{"cmd":"pip install python-arango --upgrade","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or higher.","package":"Python","optional":false}],"imports":[{"symbol":"ArangoClient","correct":"from arango import ArangoClient"}],"quickstart":{"code":"import os\nfrom arango import ArangoClient\nfrom arango.exceptions import ServerConnectionError, ArangoClientError, CollectionCreateError, DatabaseCreateError\n\n# Configuration from environment variables (replace with your ArangoDB instance details)\nARANGO_HOSTS = os.environ.get('ARANGO_HOSTS', 'http://localhost:8529')\nARANGO_USERNAME = os.environ.get('ARANGO_USERNAME', 'root')\nARANGO_PASSWORD = os.environ.get('ARANGO_PASSWORD', 'your_arangodb_password') # Default root password is often empty or 'root'\nTEST_DB_NAME = \"my_test_db_reg\"\nTEST_COLLECTION_NAME = \"my_collection_reg\"\n\ntry:\n    # Initialize the client for ArangoDB\n    client = ArangoClient(hosts=ARANGO_HOSTS)\n\n    # Connect to \"_system\" database as root user to manage other databases\n    sys_db = client.db(\"_system\", username=ARANGO_USERNAME, password=ARANGO_PASSWORD)\n\n    # Create a new database if it doesn't exist\n    if not sys_db.has_database(TEST_DB_NAME):\n        sys_db.create_database(TEST_DB_NAME)\n        print(f\"Database '{TEST_DB_NAME}' created.\")\n    else:\n        print(f\"Database '{TEST_DB_NAME}' already exists.\")\n\n    # Connect to the specific database\n    db = client.db(TEST_DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD)\n\n    # Create a new collection if it doesn't exist\n    if not db.has_collection(TEST_COLLECTION_NAME):\n        collection = db.create_collection(TEST_COLLECTION_NAME)\n        print(f\"Collection '{TEST_COLLECTION_NAME}' created.\")\n    else:\n        collection = db.collection(TEST_COLLECTION_NAME)\n        print(f\"Collection '{TEST_COLLECTION_NAME}' already exists.\")\n\n    # Insert new documents into the collection\n    docs = [\n        {\"name\": \"Alice\", \"age\": 30},\n        {\"name\": \"Bob\", \"age\": 24},\n        {\"name\": \"Charlie\", \"age\": 35}\n    ]\n    collection.insert_many(docs)\n    print(f\"Inserted {len(docs)} documents.\")\n\n    # Execute an AQL query and iterate through the result cursor\n    cursor = db.aql.execute(f\"FOR doc IN {TEST_COLLECTION_NAME} FILTER doc.age > 25 RETURN doc.name\")\n    filtered_names = [name for name in cursor]\n    print(f\"Names of people older than 25: {filtered_names}\")\n\nexcept ServerConnectionError as e:\n    print(f\"Failed to connect to ArangoDB server at {ARANGO_HOSTS}: {e}. Ensure ArangoDB is running.\")\nexcept ArangoClientError as e:\n    print(f\"ArangoDB Client Error: {e}\")\nexcept (CollectionCreateError, DatabaseCreateError) as e:\n    print(f\"Error during ArangoDB resource creation: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to connect to an ArangoDB instance, create a new database and collection (if they don't exist), insert multiple documents, and execute a simple AQL query to retrieve filtered data. Ensure ArangoDB is running and accessible, and set the `ARANGO_HOSTS`, `ARANGO_USERNAME`, and `ARANGO_PASSWORD` environment variables for authentication, or adjust the default values in the code."},"warnings":[{"fix":"Migrate your transaction logic to the new API, manually calling `begin_transaction()` and `commit()`/`abort()` as per the updated documentation. Results are returned immediately instead of job objects.","message":"The transaction API was overhauled in `python-arango` version 5.0.0 to align with ArangoDB 3.5+'s new transaction REST API. This removed context managers (e.g., `with db.begin_transaction():`) and changed method signatures. Code using the old transaction patterns will break.","severity":"breaking","affected_versions":"5.0.0+"},{"fix":"If developing an asynchronous application, install `python-arango-async` (`pip install python-arango-async`) and use its `AsyncArangoClient` and related asynchronous methods.","message":"For `asyncio` applications, use the dedicated `python-arango-async` library. `python-arango` is a synchronous driver, and using it in an asynchronous context will lead to blocking I/O and potential performance bottlenecks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that `BatchDatabase` and `BatchJob` instances are managed within a single thread context and that a new `BatchDatabase` instance is created for each batch execution if further operations are needed after a commit.","message":"Instances of `BatchDatabase` and `BatchJob` are stateful and should not be shared across multiple threads. A `BatchDatabase` instance also cannot be reused after its `commit()` method has been called.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'8.3.1':60 'activ':52 'api':34 'aql':47 'arango':7 'arangodb':4,14,38,61 'collect':42 'comprehens':33 'current':57 'databas':20,41,62,67,70 'document':24,43,66 'document-databas':65 'driver':2,12,64 'execut':46 'graph':25,44,69 'graph-databas':68 'includ':39 'interact':36 'key':28 'key-valu':27 'librari':50 'maintain':53 'manag':40 'model':19 'multi':18 'multi-model':17 'nativ':22 'nosql':63 'offici':10 'provid':31 'python':1,6,11 'python-arango':5 'queri':48 'regular':55 'releas':56 'scalabl':16 'support':23 'valu':29 'version':59","created_at":"2026-04-09T18:49:28.175344+00:00","updated_at":"2026-04-16T20:15:41.483152+00:00","problems":{"verify_error":"error: Failed to parse: `python-arango --upgrade`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `-`\npython-arango --upgrade\n              ^"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"8.3.4","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.arangodb.com","github":"https://github.com/arangodb/python-arango","docs":null,"changelog":null,"pypi":"https://pypi.org/project/python-arango/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-05","install_tag":null}}