Skip to content

Commit 6407c68

Browse files
committed
Refactor Python bindings to prioritize SQL/OpenCypher for database operations
- Updated documentation to reflect the removal of `BatchContext` and promote SQL/OpenCypher for transactions and data manipulation. - Changed examples to use SQL commands for creating and managing vertices, edges, and transactions. - Adjusted test coverage counts in documentation to reflect the current state (260 tests across 24 files). - Removed legacy importer tests in favor of SQL `IMPORT DATABASE` usage, enhancing focus on SQL-first approaches. - Improved performance tips and best practices for using NumPy and vector operations. - Cleaned up references to batch context in various documentation files, emphasizing chunked transactions instead.
1 parent a9013ab commit 6407c68

28 files changed

Lines changed: 386 additions & 1185 deletions

bindings/python/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Native Python bindings for ArcadeDB - the multi-model database that supports Graph, Document, Key/Value, Search Engine, Time Series, and Vector models.
44

5-
**Status**: ✅ Production Ready | **Tests**: 271 Passing | **Platforms**: 4 Supported
5+
**Status**: ✅ Production Ready | **Tests**: 260 Passing Across 24 Test Files | **Platforms**: 4 Supported
66

77
---
88

@@ -89,7 +89,7 @@ Import: `import arcadedb_embedded as arcadedb`
8989

9090
## 🧪 Testing
9191

92-
**Status**: 271 tests + example scripts passing on all 4 platforms
92+
**Status**: 260 tests passing across 24 test files
9393

9494
```bash
9595
# Run all tests
@@ -148,11 +148,10 @@ arcadedb_embedded/
148148
├── transactions.py # TransactionContext manager
149149
├── schema.py # Schema management API
150150
├── vector.py # Vector search and HNSW (JVector) indexing
151-
├── importer.py # Data import (CSV, JSONL)
151+
├── graph.py # Graph wrappers
152+
├── importer.py # Data import helpers (CSV/XML) + SQL import guidance
152153
├── exporter.py # Data export (JSONL, GraphML, GraphSON, CSV)
153-
├── graph.py # Graph API helpers
154-
├── batch.py # Batch operations context
155-
├── async_executor.py # Asynchronous query execution
154+
├── async_executor.py # Asynchronous command/query + record execution
156155
├── type_conversion.py # Python-Java type conversion utilities
157156
├── exceptions.py # ArcadeDBError exception
158157
├── jvm.py # JVM lifecycle management

bindings/python/docs/api-access-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Direct JVM method calls via JPype for embedded/local runtime access.
88

99
!!! note "DSL-first guidance"
1010
Prefer SQL/OpenCypher via `db.command(...)` and `db.query(...)` for schema, CRUD, and graph operations.
11-
Wrapper APIs remain available, but examples and guides are standardized on DSL usage.
11+
Wrapper APIs remain available as compatibility/reference features, but examples and guides are standardized on DSL usage.
1212

1313
### Characteristics
1414

bindings/python/docs/api/async_executor.md

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# AsyncExecutor API
22

3-
!!! warning "Experimental"
4-
`async_executor()` is experimental and not advised for production use yet. Prefer
5-
standard transactions and synchronous workflows unless you are explicitly testing
6-
or benchmarking.
3+
!!! note "Recommended usage"
4+
For application code, prefer async SQL/OpenCypher via `async_exec.command(...)`
5+
and `async_exec.query(...)`. Record-level helpers remain available for lower-level
6+
workflows and tests.
77

8-
The AsyncExecutor provides low-level async operations for parallel processing, automatic batching, and optimized WAL operations.
8+
The AsyncExecutor provides low-level async operations for parallel processing,
9+
automatic batching, and optimized WAL operations.
910

1011
!!! tip "Using Context Managers"
1112
For automatic resource cleanup, prefer using context managers:
@@ -45,11 +46,15 @@ async_exec.set_parallel_level(8) # 8 worker threads
4546
async_exec.set_commit_every(5000) # Auto-commit every 5K ops
4647
async_exec.set_back_pressure(75) # Queue back-pressure at 75%
4748

48-
# Use for bulk operations
49+
# Use for bulk SQL operations
4950
for i in range(100000):
50-
vertex = db.new_vertex("User")
51-
vertex.set("userId", i)
52-
async_exec.create_record(vertex)
51+
async_exec.command(
52+
"sql",
53+
"INSERT INTO User SET userId = :id, name = :name",
54+
callback=lambda rs: None,
55+
id=i,
56+
name=f"User {i}",
57+
)
5358

5459
# Wait for completion
5560
async_exec.wait_completion()
@@ -210,6 +215,10 @@ async_exec.create_record(
210215

211216
Schedule asynchronous record creation.
212217

218+
!!! note "Wrapper-specific API"
219+
`AsyncExecutor.create_record()` and `update_record()` operate on record wrapper
220+
objects. For non-async CRUD examples elsewhere in the docs, prefer SQL/OpenCypher.
221+
213222
**Parameters:**
214223

215224
- `record`: Document, Vertex, or Edge object to create
@@ -578,26 +587,6 @@ cpu_count = os.cpu_count() or 4
578587
async_exec.set_parallel_level(min(cpu_count, 16))
579588
```
580589

581-
## Comparison with BatchContext
582-
583-
| Feature | AsyncExecutor | BatchContext |
584-
|---------|---------------|-------------|
585-
| **Control** | ✅ Full control | ⚠️ High-level API |
586-
| **Complexity** | ⚠️ More complex | ✅ Simple |
587-
| **Progress Bar** | ❌ Manual | ✅ Built-in |
588-
| **Error Handling** | ⚠️ Callbacks | ✅ Automatic collection |
589-
| **Use Case** | Advanced tuning | Most bulk ops |
590-
591-
**When to use AsyncExecutor:**
592-
- Need fine-grained control
593-
- Custom callbacks required
594-
- Performance tuning critical
595-
596-
**When to use BatchContext:**
597-
- Standard bulk operations
598-
- Want progress tracking
599-
- Prefer simple API
600-
601590
## Troubleshooting
602591

603592
### Out of Memory Errors
@@ -636,7 +625,6 @@ if async_exec.is_pending():
636625

637626
## See Also
638627

639-
- **[BatchContext API](batch.md)** - High-level batch processing
640628
- **[Transactions API](transactions.md)** - Transaction management
641629
- **[Database API](database.md)** - Database operations
642630
- **[Example 05: CSV Import](../examples/05_csv_import_graph.md)** - Real-world usage

0 commit comments

Comments
 (0)