Skip to content

Basic Examples

This page provides quick links to basic ArcadeDB examples to get you started.

Getting Started Examples

Document Store

Start with the simplest use case - storing and querying documents:

Example 01 - Simple Document Store

Learn how to: - Create a database and document types - Insert documents with various data types - Query using SQL - Handle NULL values

Graph Database

Build your first graph database with vertices and edges:

Example 02 - Social Network Graph

Learn how to:

  • Create vertices and edges
  • Use OpenCypher queries for graph traversal
  • Traverse graph relationships efficiently
  • Implement social network patterns

Quick Start Code

Opening a Database

import arcadedb_embedded as arcadedb

# Create a new database with context manager (auto-closes)
with arcadedb.create_database("./mydb") as db:
    # Your operations here
    pass

# Or open existing database
with arcadedb.open_database("./mydb") as db:
    # Perform operations
    pass

Basic Document Operations

import arcadedb_embedded as arcadedb

with arcadedb.create_database("./mydb") as db:
    # Create document type (schema ops are auto-transactional)
    db.schema.create_document_type("Product")

    # Insert document
    with db.transaction():
        product = db.new_document("Product")
        product.set("name", "Laptop").set("price", 999.99).set("inStock", True)
        product.save()

    # Query documents (reads don't need transaction)
    results = db.query("sql", "SELECT FROM Product WHERE price < 1000")
    for record in results:
        print(record.get("name"), record.get("price"))

Basic Graph Operations

import arcadedb_embedded as arcadedb

with arcadedb.create_database("./mydb") as db:
    # Create vertex types (schema ops are auto-transactional)
    db.schema.create_vertex_type("Person")
    db.schema.create_edge_type("Knows")

    # Create vertices and edges
    with db.transaction():
        alice = db.new_vertex("Person")
        alice.set("name", "Alice").save()

        bob = db.new_vertex("Person")
        bob.set("name", "Bob").save()

        edge = alice.new_edge("Knows", bob)
        edge.save()

    # Traverse graph (reads don't need transaction)
    results = db.query("opencypher", """
        MATCH (p:Person)-[:Knows]->(other:Person)
        RETURN other.name as name
        ORDER BY name
    """)

    for record in results:
        print(record.get("name"))

More Examples

Browse all examples:

Source Code

All example source code is available in the examples/ directory of the repository.

Additional Resources