Skip to content

Commit d867bc1

Browse files
committed
feat: Add graph_batch and import_documents methods with usage examples and clarify transaction management
1 parent f957f25 commit d867bc1

2 files changed

Lines changed: 76 additions & 6 deletions

File tree

bindings/python/docs/api/database.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,70 @@ synchronous workflows.
543543

544544
---
545545

546+
### graph_batch
547+
548+
```python
549+
db.graph_batch(...) -> GraphBatch
550+
```
551+
552+
Create a `GraphBatch` helper for high-throughput graph ingestion.
553+
554+
This is the repository's recommended bulk graph-ingest path from Python when you need to
555+
load many vertices and edges efficiently.
556+
557+
**Common options:**
558+
559+
- `batch_size`: buffered edge batch size
560+
- `expected_edge_count`: tuning hint for large graph loads
561+
- `light_edges`: create property-less edges as light edges
562+
- `commit_every`: commit cadence during flush
563+
- `use_wal`: enable WAL for higher durability
564+
- `parallel_flush`: parallelize flush/close work
565+
566+
**Example:**
567+
568+
```python
569+
with db.graph_batch(expected_edge_count=50000) as batch:
570+
alice = batch.create_vertex("Person", name="Alice")
571+
bob = batch.create_vertex("Person", name="Bob")
572+
batch.new_edge(alice, "Knows", bob, since=2024)
573+
```
574+
575+
See [Graph Operations](../guide/graphs.md) and the graph benchmark examples for guidance.
576+
577+
---
578+
579+
### import_documents
580+
581+
```python
582+
db.import_documents(source: str, document_type: str = "Document", ...) -> ImportResult
583+
```
584+
585+
Import document-shaped data through ArcadeDB's Java importer framework.
586+
587+
This is a narrow wrapper for file-based document imports such as CSV into a document
588+
type. It is supported, but it is not the recommended default for large Python-managed
589+
bulk ingest.
590+
591+
**Common options:**
592+
593+
- `file_type`: importer file type such as `"csv"`
594+
- `delimiter`: delimiter override for delimited formats
595+
- `commit_every`: importer transaction split interval
596+
- `parallel`: importer worker count
597+
- `wal`: WAL override during import
598+
- `extra_settings`: additional raw importer settings
599+
600+
**Example:**
601+
602+
```python
603+
db.import_documents("./movies.csv", document_type="Movie", file_type="csv")
604+
```
605+
606+
For bulk table/document ingest from Python, prefer async SQL with a single async worker.
607+
608+
---
609+
546610
### export_database
547611

548612
```python

bindings/python/docs/api/transactions.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ It is important to distinguish between operations that require explicit transact
2626
| :--- | :--- | :--- |
2727
| **Schema Operations** | `create_vertex_type()`, `create_property()`, `create_index()`, `db.command("sql", "DROP INDEX...")` | **Auto-transactional** (Do NOT wrap in `with db.transaction():`) |
2828
| **Data Write** | `db.command("sql", "INSERT...")`, `db.command("sql", "UPDATE...")`, `db.command("sql", "DELETE...")`, `db.command("opencypher", "CREATE ...")` | **Required** (Wrap in `with db.transaction():`) |
29-
| **Bulk Operations** | `db.command("sql", "IMPORT DATABASE...")` | **Auto-transactional** (Built-in transaction management) |
29+
| **Bulk Operations** | `db.command("sql", "IMPORT DATABASE...")`, `db.import_documents(...)`, `db.graph_batch(...)` | **Auto-transactional / auto-managed** (Built-in transaction management) |
3030
| **Data Read** | `db.query()`, `db.command("sql", "SELECT...")`, `db.lookup_by_rid()` | **Optional** (Can run outside transaction for better performance) |
3131
| **Vector Operations** | `db.create_vector_index()` | **Auto-transactional** (Do NOT wrap) |
3232

3333
### Key Distinction: `db.query()` vs `db.command()`
3434

3535
- **`db.query()`**: Always used for **read-only queries**. Returns a `ResultSet` with read-only results. **Does NOT require a transaction.**
36-
- **`db.command()`**: Used for **both DDL and DML operations**:
37-
- DML Read: `SELECT` queries (returns ResultSet, optional transaction)
38-
- DML Write: `INSERT`, `UPDATE`, `DELETE` (requires transaction)
39-
- DDL: `CREATE TYPE`, `CREATE PROPERTY`, `CREATE INDEX`, `DROP`, etc. (auto-transactional)
40-
- Bulk: `IMPORT DATABASE`, `MOVE` (auto-transactional)
36+
- **`db.command()`**: Used for **both DDL and DML operations**. For read statements such
37+
as `SELECT`, it returns a `ResultSet` and can run outside a transaction. For write
38+
statements such as `INSERT`, `UPDATE`, and `DELETE`, wrap it in
39+
`with db.transaction():`. DDL such as `CREATE TYPE`, `CREATE PROPERTY`, `CREATE INDEX`,
40+
`DROP`, plus bulk commands such as `IMPORT DATABASE` and `MOVE`, remain
41+
auto-transactional.
42+
- **`db.import_documents()`**: Runs the Java importer through the narrow document-import
43+
wrapper. It manages its own importer/async lifecycle, so you should not wrap it in
44+
`with db.transaction():`.
45+
- **`db.graph_batch()`**: Creates the engine-backed bulk graph-ingest helper. It manages
46+
its own flush/commit lifecycle, so you should not wrap it in `with db.transaction():`.
4147

4248
### Best Practice Pattern
4349

0 commit comments

Comments
 (0)