<!--
SPDX-FileCopyrightText: 2026 BaseLabs Holdings LLC

SPDX-License-Identifier: MIT
-->

# Load data

Use this guide to choose an import, graph batch, or replayable upsert for
data that you need to load into ArcadeDB.

## Import a file on the server

Use `Arcadic.Import.database/3` for CSV, JSON, JSONL, GraphML, Neo4j,
OrientDB, and ArcadeDB exports. Give ArcadeDB a URL it can reach. The client
allowlists URL characters and the `http`, `https`, and `file` schemes. ArcadeDB
blocks private and loopback HTTP sources by default.

```elixir
{:ok, _} =
  Arcadic.Import.database(conn, "file:///srv/exports/people.csv",
    with: [commitEvery: 10_000]
  )
```

`:with` accepts numeric, boolean, and allowlisted string values. If the
server returns a successful HTTP status with a result row marked `"FAIL"`,
Arcadic returns `:import_failed`. Use `Arcadic.Export.database/3` for a
server-side export. Give it a bare name inside the server's exports directory.

## Load records from Elixir

Use `Arcadic.Bulk.ingest/3` to create vertices and edges already held by the
client. Declare their types first. Give vertices temporary `"@id"` keys and
reference those keys from edge `"@from"` and `"@to"` fields. The result's
`id_mapping` gives you the assigned RIDs. See the [GraphRAG tutorial](../tutorials/graphrag.livemd)
for a complete batch. See `Arcadic.Bulk` for commit behavior and failure
reconciliation.

Use `UNWIND` with `MERGE` for replayable upserts when the database
enforces the matching identity. Use `ON CREATE SET` and `ON MATCH SET` to
apply different properties on creation and update.

```elixir
Arcadic.command(
  conn,
  "UNWIND $rows AS r MERGE (n:User {id: r.id}) SET n += r.props",
  %{"rows" => rows}
)
```

For documents over gRPC, `Arcadic.Ingest.insert/4` returns insert counts.
Use `:chunk_size` to send a client stream. For writes that must participate
in an existing transaction, use statements on its connection.

## Choose the index creation order

Create the type, load records, and create the index if that index can backfill
existing rows. `LSM_TREE` and dense `LSM_VECTOR` indexes backfill. For sparse
indexes, check [Compatibility](../topics/client/compatibility.md). Use a
transaction to group incremental statement writes under one commit.
