arcadedb-python 0.2.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/.gitignore +7 -0
  2. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/CHANGELOG.md +68 -0
  3. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/PKG-INFO +137 -67
  4. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/README.md +136 -66
  5. arcadedb_python-0.3.1/arcadedb_python/__init__.py +82 -0
  6. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/api/client.py +6 -13
  7. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/api/sync.py +23 -20
  8. arcadedb_python-0.3.1/arcadedb_python/dao/database.py +1300 -0
  9. arcadedb_python-0.3.1/arcadedb_python/exceptions.py +150 -0
  10. arcadedb_python-0.3.1/docs/API.md +719 -0
  11. arcadedb_python-0.3.1/examples/quickstart_example.py +210 -0
  12. arcadedb_python-0.3.1/examples/test_query_languages.py +121 -0
  13. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/pyproject.toml +143 -139
  14. arcadedb_python-0.3.1/tests/test_enhanced_features.py +423 -0
  15. arcadedb_python-0.2.0/arcadedb_python/__init__.py +0 -40
  16. arcadedb_python-0.2.0/arcadedb_python/dao/database.py +0 -321
  17. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/LICENSE +0 -0
  18. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/api/__init__.py +0 -0
  19. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/api/config.py +0 -0
  20. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/dao/__init__.py +0 -0
  21. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/model/__init__.py +0 -0
  22. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/model/database.py +0 -0
  23. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/arcadedb_python/model/request.py +0 -0
  24. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/__init__.py +0 -0
  25. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/api/__init__.py +0 -0
  26. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/api/test_client.py +0 -0
  27. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/api/test_config.py +0 -0
  28. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/model/__init__.py +0 -0
  29. {arcadedb_python-0.2.0 → arcadedb_python-0.3.1}/tests/model/test_request.py +0 -0
@@ -163,6 +163,13 @@ cython_debug/
163
163
  # VS Code
164
164
  .vscode/
165
165
 
166
+ # Cursor
167
+ .cursorignore
168
+ .cursorindexingignore
169
+ *.cursormemory
170
+ .cursormemory
171
+ memory-bank/
172
+
166
173
  # macOS
167
174
  .DS_Store
168
175
 
@@ -5,6 +5,74 @@ All notable changes to the ArcadeDB Python Driver will be documented in this fil
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+
9
+ ## [0.3.1] - 20025-10-21
10
+
11
+ **Bug fixes for 0.3.1, README.md now has correct Quick Start Code, docs/API.md added, examples added**
12
+
13
+ ## Fixed
14
+ - In release 0.3.1 will include bug #1 fix (Can't instantiate DatabaseDao). Was fixed with pull request (merged in) #2 Fix string escaping in query parameters and property assignments. This didn't show up with python 3.12, 3.13, but did with python 3.10, 3.11
15
+ Was fixed in `dao/database.py` with different code for escaping parameters and property assignments.
16
+ - For bug #3 Quick Start: Basic Usage fails, the README.md quick start was updated to have the correct working code to upe
17
+
18
+ ### Documentation
19
+ - Updated `README.md`: the `README.md` now has the correct working quick start SQL code (have to use SyncClient and give to DatabaseDao, etc), added links to `docs/API.md`, 2 examples/ files, added cypher and gremlin code
20
+ - Added `docs/API.md` documenting the classes and functions / parameters, 4 temp docs while developing removed
21
+
22
+ ### Added
23
+ - In examples/ added `quickstart_example.py` with quick start code from `README.md`, `test_query_langages.py` with cypher and gremlin code from `README.md`, `enhanced_features_demo.py` from development removed
24
+
25
+ ### Changed
26
+ - Updated `pyproject.toml` to have release 0.3.1
27
+ - `pyproject.toml`, `manifest.in`: docs and examples added to source release
28
+ - `client.py` headers() no content type logging level changed from warning to debug
29
+ - `sync.py` get() and post() logging level changed from info to debug (now won't see all sql calls by default),
30
+ - `__init__.py` updated to version 0.3.1
31
+
32
+
33
+ ## [0.3.0] - 2025-09-23
34
+
35
+ **Major Enhancement Release for LlamaIndex Integration**
36
+
37
+ ### Added
38
+ - **Comprehensive Exception System**: 10 typed exception classes for better error handling
39
+ - `ArcadeDBException`, `QueryParsingException`, `TransactionException`, `BulkOperationException`, `VectorOperationException`, etc.
40
+ - **Bulk Operations API**: High-performance batch processing
41
+ - `bulk_insert()`, `bulk_upsert()`, `bulk_delete()` methods with configurable batching
42
+ - `execute_batch()` and `execute_transaction()` for multiple queries
43
+ - **Vector Operations**: Native vector similarity search support
44
+ - `vector_search()` with similarity scoring and filtering
45
+ - `create_vector_index()` for performance optimization
46
+ - `batch_vector_search()` for multiple searches
47
+ - **Enhanced Query Parsing**: Robust fallback mechanisms
48
+ - `get_records()` with UNION fallback to individual queries
49
+ - `get_triplets()` with MATCH fallback to edge traversal
50
+ - **Advanced Transaction Management**: Automatic retry and safety features
51
+ - `safe_delete_all()` with batching for non-idempotent operations
52
+ - `safe_bulk_operation()` with retry logic and exponential backoff
53
+ - Automatic retry for non-idempotent queries as commands
54
+ - **Comprehensive Test Suite**: 28 tests covering all new features
55
+
56
+ ### Changed
57
+ - Enhanced error handling throughout the codebase with automatic error parsing
58
+ - Improved transaction safety with automatic rollback on failures
59
+ - Better input validation with clear error messages
60
+
61
+ ### Fixed
62
+ - **Critical LlamaIndex Integration Issues**:
63
+ - UNION and MATCH query parsing failures
64
+ - Non-idempotent DELETE operation restrictions
65
+ - Generic error handling that hindered debugging
66
+ - Performance issues with large datasets
67
+ - Vector search limitations
68
+
69
+ ### Performance
70
+ - **10x faster** bulk operations compared to individual queries
71
+ - Intelligent batching prevents memory issues with large datasets
72
+ - Vector operations optimized with index support
73
+
74
+ **Impact**: Expected LlamaIndex integration test success rate improvement from 20% to 80-100%
75
+
8
76
  ## [0.2.0] - 2025-09-20
9
77
 
10
78
  **Maintainer**: Steve Reiner
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arcadedb-python
3
- Version: 0.2.0
3
+ Version: 0.3.1
4
4
  Summary: Python driver for ArcadeDB - Multi-Model Database with Graph, Document, Key-Value, Vector, and Time-Series support
5
5
  Project-URL: Homepage, https://github.com/stevereiner/arcadedb-python
6
6
  Project-URL: Documentation, https://docs.arcadedb.com/
@@ -119,72 +119,94 @@ uv pip install arcadedb-python[dev]
119
119
  ### Basic Usage
120
120
 
121
121
  ```python
122
- from arcadedb_python import DatabaseDao
122
+ from arcadedb_python import DatabaseDao, SyncClient
123
123
 
124
- # Connect to ArcadeDB
125
- db = DatabaseDao(
124
+ # Step 1: Create a client connection
125
+ client = SyncClient(
126
126
  host="localhost",
127
127
  port=2480,
128
- database="mydb",
129
128
  username="root",
130
129
  password="playwithdata"
131
130
  )
132
131
 
133
- # Execute SQL queries
134
- result = db.query("sql", "SELECT FROM V LIMIT 10")
135
- print(result)
132
+ # Step 2: Connect to database (or create it)
133
+ if not DatabaseDao.exists(client, "mydb"):
134
+ db = DatabaseDao.create(client, "mydb")
135
+ else:
136
+ db = DatabaseDao(client, "mydb")
137
+
138
+ # Step 3: Create schema (DDL requires is_command=True)
139
+ db.query("sql", "CREATE VERTEX TYPE Person IF NOT EXISTS", is_command=True)
136
140
 
137
- # Create vertices and edges
138
- db.command("sql", "CREATE VERTEX TYPE Person")
139
- db.command("sql", "INSERT INTO Person SET name = 'John', age = 30")
141
+ # Step 4: Insert data (DML requires is_command=True)
142
+ db.query("sql", "INSERT INTO Person SET name = 'John', age = 30", is_command=True)
143
+
144
+ # Step 5: Query data
145
+ result = db.query("sql", "SELECT FROM Person LIMIT 10")
146
+ print(result)
140
147
 
141
- # Graph traversal
148
+ # Step 6: Graph traversal
142
149
  result = db.query("sql", """
143
150
  MATCH {type: Person, as: person}
144
151
  RETURN person.name, person.age
145
152
  """)
153
+ print(result)
146
154
  ```
147
155
 
148
- ### Configuration
156
+ ### Important Notes
149
157
 
150
- ```python
151
- from arcadedb_python import ArcadeDBConfig, DatabaseDao
158
+ - **Use `SyncClient`** to create connections, not `DatabaseDao` directly
159
+ - **Use `is_command=True`** for DDL/DML operations (CREATE, INSERT, UPDATE, DELETE)
160
+ - **SELECT queries** don't need `is_command=True` (it defaults to False)
161
+ - **Create vertex types first** before querying (V and E types don't exist by default)
162
+ ```
152
163
 
153
- # Using configuration object
154
- config = ArcadeDBConfig(
155
- host="localhost",
156
- port=2480,
157
- username="root",
158
- password="playwithdata"
159
- )
164
+ ## API Documentation
160
165
 
161
- db = DatabaseDao.from_config(config, "mydb")
162
- ```
166
+ For complete API reference including all methods, parameters, exceptions, and detailed examples:
163
167
 
164
- ### Async Operations
168
+ **📚 [docs/API.md](docs/API.md)** - Comprehensive API documentation covering:
169
+ - `SyncClient` - Connection management
170
+ - `DatabaseDao` - All database operations (query, transactions, bulk operations)
171
+ - Exception handling and error types
172
+ - Configuration options
173
+ - Complete code examples
165
174
 
166
- ```python
167
- import asyncio
168
- from arcadedb_python import DatabaseDao
175
+ ## Examples
176
+
177
+ ### Available Examples
178
+
179
+ **[examples/quickstart_example.py](examples/quickstart_example.py)**
180
+ - Complete walkthrough of all Quick Start code
181
+ - All data models: Graph, Document, Key-Value, Time-Series, Vector storage
182
+ - Step-by-step explanations
183
+ - Error handling examples
169
184
 
170
- async def main():
171
- db = DatabaseDao("localhost", 2480, "mydb", "root", "playwithdata")
172
-
173
- # Async query execution
174
- result = await db.query_async("sql", "SELECT FROM V LIMIT 10")
175
- print(result)
185
+ **[examples/test_query_languages.py](examples/test_query_languages.py)**
186
+ - openCypher query examples
187
+ - Gremlin query examples
188
+ - Database creation and cleanup
189
+
190
+ ### Running Examples
191
+
192
+ ```bash
193
+ # Complete quickstart with all features
194
+ python examples/quickstart_example.py
176
195
 
177
- asyncio.run(main())
196
+ # Test openCypher and Gremlin queries
197
+ python examples/test_query_languages.py
178
198
  ```
179
199
 
200
+ **Requirements:** ArcadeDB must be running on `localhost:2480` with default credentials (`root`/`playwithdata`)
201
+
180
202
  ## Advanced Usage
181
203
 
182
204
  ### Working with Different Data Models
183
205
 
184
206
  ```python
185
207
  # Document operations
186
- db.command("sql", "CREATE DOCUMENT TYPE Product")
187
- db.command("sql", """
208
+ db.query("sql", "CREATE DOCUMENT TYPE Product IF NOT EXISTS", is_command=True)
209
+ db.query("sql", """
188
210
  INSERT INTO Product CONTENT {
189
211
  "name": "Laptop",
190
212
  "price": 999.99,
@@ -193,70 +215,118 @@ db.command("sql", """
193
215
  "ram": "16GB"
194
216
  }
195
217
  }
196
- """)
218
+ """, is_command=True)
197
219
 
198
220
  # Graph operations
199
- db.command("sql", "CREATE VERTEX TYPE Customer")
200
- db.command("sql", "CREATE EDGE TYPE Purchased")
201
- db.command("sql", """
221
+ db.query("sql", "CREATE VERTEX TYPE Customer IF NOT EXISTS", is_command=True)
222
+ db.query("sql", "CREATE EDGE TYPE Purchased IF NOT EXISTS", is_command=True)
223
+ db.query("sql", """
202
224
  CREATE EDGE Purchased
203
225
  FROM (SELECT FROM Customer WHERE name = 'John')
204
226
  TO (SELECT FROM Product WHERE name = 'Laptop')
205
- SET date = date(), amount = 999.99
206
- """)
227
+ SET date = sysdate(), amount = 999.99
228
+ """, is_command=True)
207
229
 
208
230
  # Key-Value operations
209
- db.command("sql", "CREATE DOCUMENT TYPE Settings")
210
- db.command("sql", "INSERT INTO Settings SET key = 'theme', value = 'dark'")
231
+ db.query("sql", "CREATE DOCUMENT TYPE Settings IF NOT EXISTS", is_command=True)
232
+ db.query("sql", "INSERT INTO Settings SET key = 'theme', value = 'dark'", is_command=True)
211
233
 
212
234
  # Time-Series operations
213
- db.command("sql", "CREATE VERTEX TYPE Sensor")
214
- db.command("sql", """
235
+ db.query("sql", "CREATE VERTEX TYPE Sensor IF NOT EXISTS", is_command=True)
236
+ db.query("sql", """
215
237
  INSERT INTO Sensor SET
216
238
  sensor_id = 'temp_01',
217
239
  timestamp = sysdate(),
218
240
  temperature = 23.5
219
- """)
241
+ """, is_command=True)
220
242
  ```
221
243
 
222
244
  ### Vector Search (for AI/ML applications)
223
245
 
224
246
  ```python
247
+ # Note: Vector similarity search is not currently supported by this driver
248
+ # You can store vector embeddings as arrays
249
+
225
250
  # Store embeddings
226
- db.command("sql", """
227
- CREATE VERTEX TYPE Document SET
251
+ db.query("sql", "CREATE VERTEX TYPE DocRecord IF NOT EXISTS", is_command=True)
252
+ db.query("sql", """
253
+ INSERT INTO DocRecord SET
228
254
  title = 'AI Research Paper',
229
- embedding = [0.1, 0.2, 0.3, ...], # Your vector embeddings
255
+ embedding = [0.1, 0.2, 0.3, 0.4, 0.5],
230
256
  content = 'Full document text...'
231
- """)
257
+ """, is_command=True)
232
258
 
233
- # Vector similarity search
234
- result = db.query("sql", """
235
- SELECT title, content,
236
- cosine_similarity(embedding, [0.1, 0.2, 0.3, ...]) as similarity
237
- FROM Document
238
- ORDER BY similarity DESC
239
- LIMIT 10
240
- """)
259
+ # Query documents with embeddings
260
+ result = db.query("sql", "SELECT title, embedding FROM DocRecord WHERE title = 'AI Research Paper'")
261
+ ```
262
+
263
+ ### Using openCypher
264
+
265
+ ```python
266
+ # Note: openCypher support may have different performance characteristics than native SQL
267
+ # For large operations, consider using ArcadeDB's native SQL or Java API
268
+
269
+ # Create nodes
270
+ db.query("cypher", "CREATE (p:Person {name: 'John', age: 30})", is_command=True)
271
+ db.query("cypher", "CREATE (p:Person {name: 'Jane', age: 25})", is_command=True)
272
+
273
+ # Create relationship
274
+ db.query("cypher", """
275
+ MATCH (a:Person {name: 'John'}), (b:Person {name: 'Jane'})
276
+ CREATE (a)-[:KNOWS]->(b)
277
+ """, is_command=True)
278
+
279
+ # Query with openCypher
280
+ result = db.query("cypher", "MATCH (p:Person) RETURN p.name, p.age")
281
+ print(result)
282
+ ```
283
+
284
+ ### Using Gremlin
285
+
286
+ ```python
287
+ # Note: Gremlin support may have different performance characteristics than native SQL
288
+ # For large operations, consider using ArcadeDB's native SQL or Java API
289
+
290
+ # Add vertices
291
+ db.query("gremlin", "g.addV('Person').property('name', 'John').property('age', 30)", is_command=True)
292
+ db.query("gremlin", "g.addV('Person').property('name', 'Jane').property('age', 25)", is_command=True)
293
+
294
+ # Query with Gremlin
295
+ result = db.query("gremlin", "g.V().hasLabel('Person').values('name')")
296
+ print(result)
297
+
298
+ # Traversal
299
+ result = db.query("gremlin", "g.V().hasLabel('Person').has('age', gt(20)).values('name', 'age')")
300
+ print(result)
241
301
  ```
242
302
 
243
303
  ## Configuration Options
244
304
 
305
+ ### SyncClient Parameters
306
+
245
307
  | Parameter | Type | Default | Description |
246
308
  |-----------|------|---------|-------------|
247
309
  | `host` | str | "localhost" | ArcadeDB server hostname |
248
310
  | `port` | int | 2480 | ArcadeDB server port |
249
- | `username` | str | "root" | Database username |
311
+ | `username` | str | None | Database username |
250
312
  | `password` | str | None | Database password |
251
- | `database` | str | None | Database name |
252
- | `use_ssl` | bool | False | Enable SSL connection |
253
- | `timeout` | int | 30 | Request timeout in seconds |
254
- | `pool_size` | int | 10 | Connection pool size |
313
+ | `protocol` | str | "http" | Protocol ("http" or "https") |
314
+
315
+ ### DatabaseDao.query() Parameters
316
+
317
+ | Parameter | Type | Default | Description |
318
+ |-----------|------|---------|-------------|
319
+ | `language` | str | Required | Query language: "sql", "cypher", "gremlin", "graphql", "mongo" |
320
+ | `command` | str | Required | The query/command to execute |
321
+ | `is_command` | bool | False | Set True for DDL/DML (CREATE, INSERT, UPDATE, DELETE) |
322
+ | `limit` | int | None | Maximum number of results |
323
+ | `params` | dict | None | Query parameters |
324
+ | `session_id` | str | None | Transaction session ID |
255
325
 
256
326
  ## Requirements
257
327
 
258
- - **Python**: 3.8 or higher
259
- - **ArcadeDB**: Version 23.10 or higher
328
+ - **Python**: 3.10 or higher
329
+ - **ArcadeDB**: Version 25.8.1 or higher
260
330
  - **Dependencies**:
261
331
  - `requests` >= 2.25.0
262
332
  - `retry` >= 0.9.2
@@ -70,72 +70,94 @@ uv pip install arcadedb-python[dev]
70
70
  ### Basic Usage
71
71
 
72
72
  ```python
73
- from arcadedb_python import DatabaseDao
73
+ from arcadedb_python import DatabaseDao, SyncClient
74
74
 
75
- # Connect to ArcadeDB
76
- db = DatabaseDao(
75
+ # Step 1: Create a client connection
76
+ client = SyncClient(
77
77
  host="localhost",
78
78
  port=2480,
79
- database="mydb",
80
79
  username="root",
81
80
  password="playwithdata"
82
81
  )
83
82
 
84
- # Execute SQL queries
85
- result = db.query("sql", "SELECT FROM V LIMIT 10")
86
- print(result)
83
+ # Step 2: Connect to database (or create it)
84
+ if not DatabaseDao.exists(client, "mydb"):
85
+ db = DatabaseDao.create(client, "mydb")
86
+ else:
87
+ db = DatabaseDao(client, "mydb")
88
+
89
+ # Step 3: Create schema (DDL requires is_command=True)
90
+ db.query("sql", "CREATE VERTEX TYPE Person IF NOT EXISTS", is_command=True)
87
91
 
88
- # Create vertices and edges
89
- db.command("sql", "CREATE VERTEX TYPE Person")
90
- db.command("sql", "INSERT INTO Person SET name = 'John', age = 30")
92
+ # Step 4: Insert data (DML requires is_command=True)
93
+ db.query("sql", "INSERT INTO Person SET name = 'John', age = 30", is_command=True)
94
+
95
+ # Step 5: Query data
96
+ result = db.query("sql", "SELECT FROM Person LIMIT 10")
97
+ print(result)
91
98
 
92
- # Graph traversal
99
+ # Step 6: Graph traversal
93
100
  result = db.query("sql", """
94
101
  MATCH {type: Person, as: person}
95
102
  RETURN person.name, person.age
96
103
  """)
104
+ print(result)
97
105
  ```
98
106
 
99
- ### Configuration
107
+ ### Important Notes
100
108
 
101
- ```python
102
- from arcadedb_python import ArcadeDBConfig, DatabaseDao
109
+ - **Use `SyncClient`** to create connections, not `DatabaseDao` directly
110
+ - **Use `is_command=True`** for DDL/DML operations (CREATE, INSERT, UPDATE, DELETE)
111
+ - **SELECT queries** don't need `is_command=True` (it defaults to False)
112
+ - **Create vertex types first** before querying (V and E types don't exist by default)
113
+ ```
103
114
 
104
- # Using configuration object
105
- config = ArcadeDBConfig(
106
- host="localhost",
107
- port=2480,
108
- username="root",
109
- password="playwithdata"
110
- )
115
+ ## API Documentation
111
116
 
112
- db = DatabaseDao.from_config(config, "mydb")
113
- ```
117
+ For complete API reference including all methods, parameters, exceptions, and detailed examples:
114
118
 
115
- ### Async Operations
119
+ **📚 [docs/API.md](docs/API.md)** - Comprehensive API documentation covering:
120
+ - `SyncClient` - Connection management
121
+ - `DatabaseDao` - All database operations (query, transactions, bulk operations)
122
+ - Exception handling and error types
123
+ - Configuration options
124
+ - Complete code examples
116
125
 
117
- ```python
118
- import asyncio
119
- from arcadedb_python import DatabaseDao
126
+ ## Examples
127
+
128
+ ### Available Examples
129
+
130
+ **[examples/quickstart_example.py](examples/quickstart_example.py)**
131
+ - Complete walkthrough of all Quick Start code
132
+ - All data models: Graph, Document, Key-Value, Time-Series, Vector storage
133
+ - Step-by-step explanations
134
+ - Error handling examples
120
135
 
121
- async def main():
122
- db = DatabaseDao("localhost", 2480, "mydb", "root", "playwithdata")
123
-
124
- # Async query execution
125
- result = await db.query_async("sql", "SELECT FROM V LIMIT 10")
126
- print(result)
136
+ **[examples/test_query_languages.py](examples/test_query_languages.py)**
137
+ - openCypher query examples
138
+ - Gremlin query examples
139
+ - Database creation and cleanup
140
+
141
+ ### Running Examples
142
+
143
+ ```bash
144
+ # Complete quickstart with all features
145
+ python examples/quickstart_example.py
127
146
 
128
- asyncio.run(main())
147
+ # Test openCypher and Gremlin queries
148
+ python examples/test_query_languages.py
129
149
  ```
130
150
 
151
+ **Requirements:** ArcadeDB must be running on `localhost:2480` with default credentials (`root`/`playwithdata`)
152
+
131
153
  ## Advanced Usage
132
154
 
133
155
  ### Working with Different Data Models
134
156
 
135
157
  ```python
136
158
  # Document operations
137
- db.command("sql", "CREATE DOCUMENT TYPE Product")
138
- db.command("sql", """
159
+ db.query("sql", "CREATE DOCUMENT TYPE Product IF NOT EXISTS", is_command=True)
160
+ db.query("sql", """
139
161
  INSERT INTO Product CONTENT {
140
162
  "name": "Laptop",
141
163
  "price": 999.99,
@@ -144,70 +166,118 @@ db.command("sql", """
144
166
  "ram": "16GB"
145
167
  }
146
168
  }
147
- """)
169
+ """, is_command=True)
148
170
 
149
171
  # Graph operations
150
- db.command("sql", "CREATE VERTEX TYPE Customer")
151
- db.command("sql", "CREATE EDGE TYPE Purchased")
152
- db.command("sql", """
172
+ db.query("sql", "CREATE VERTEX TYPE Customer IF NOT EXISTS", is_command=True)
173
+ db.query("sql", "CREATE EDGE TYPE Purchased IF NOT EXISTS", is_command=True)
174
+ db.query("sql", """
153
175
  CREATE EDGE Purchased
154
176
  FROM (SELECT FROM Customer WHERE name = 'John')
155
177
  TO (SELECT FROM Product WHERE name = 'Laptop')
156
- SET date = date(), amount = 999.99
157
- """)
178
+ SET date = sysdate(), amount = 999.99
179
+ """, is_command=True)
158
180
 
159
181
  # Key-Value operations
160
- db.command("sql", "CREATE DOCUMENT TYPE Settings")
161
- db.command("sql", "INSERT INTO Settings SET key = 'theme', value = 'dark'")
182
+ db.query("sql", "CREATE DOCUMENT TYPE Settings IF NOT EXISTS", is_command=True)
183
+ db.query("sql", "INSERT INTO Settings SET key = 'theme', value = 'dark'", is_command=True)
162
184
 
163
185
  # Time-Series operations
164
- db.command("sql", "CREATE VERTEX TYPE Sensor")
165
- db.command("sql", """
186
+ db.query("sql", "CREATE VERTEX TYPE Sensor IF NOT EXISTS", is_command=True)
187
+ db.query("sql", """
166
188
  INSERT INTO Sensor SET
167
189
  sensor_id = 'temp_01',
168
190
  timestamp = sysdate(),
169
191
  temperature = 23.5
170
- """)
192
+ """, is_command=True)
171
193
  ```
172
194
 
173
195
  ### Vector Search (for AI/ML applications)
174
196
 
175
197
  ```python
198
+ # Note: Vector similarity search is not currently supported by this driver
199
+ # You can store vector embeddings as arrays
200
+
176
201
  # Store embeddings
177
- db.command("sql", """
178
- CREATE VERTEX TYPE Document SET
202
+ db.query("sql", "CREATE VERTEX TYPE DocRecord IF NOT EXISTS", is_command=True)
203
+ db.query("sql", """
204
+ INSERT INTO DocRecord SET
179
205
  title = 'AI Research Paper',
180
- embedding = [0.1, 0.2, 0.3, ...], # Your vector embeddings
206
+ embedding = [0.1, 0.2, 0.3, 0.4, 0.5],
181
207
  content = 'Full document text...'
182
- """)
208
+ """, is_command=True)
183
209
 
184
- # Vector similarity search
185
- result = db.query("sql", """
186
- SELECT title, content,
187
- cosine_similarity(embedding, [0.1, 0.2, 0.3, ...]) as similarity
188
- FROM Document
189
- ORDER BY similarity DESC
190
- LIMIT 10
191
- """)
210
+ # Query documents with embeddings
211
+ result = db.query("sql", "SELECT title, embedding FROM DocRecord WHERE title = 'AI Research Paper'")
212
+ ```
213
+
214
+ ### Using openCypher
215
+
216
+ ```python
217
+ # Note: openCypher support may have different performance characteristics than native SQL
218
+ # For large operations, consider using ArcadeDB's native SQL or Java API
219
+
220
+ # Create nodes
221
+ db.query("cypher", "CREATE (p:Person {name: 'John', age: 30})", is_command=True)
222
+ db.query("cypher", "CREATE (p:Person {name: 'Jane', age: 25})", is_command=True)
223
+
224
+ # Create relationship
225
+ db.query("cypher", """
226
+ MATCH (a:Person {name: 'John'}), (b:Person {name: 'Jane'})
227
+ CREATE (a)-[:KNOWS]->(b)
228
+ """, is_command=True)
229
+
230
+ # Query with openCypher
231
+ result = db.query("cypher", "MATCH (p:Person) RETURN p.name, p.age")
232
+ print(result)
233
+ ```
234
+
235
+ ### Using Gremlin
236
+
237
+ ```python
238
+ # Note: Gremlin support may have different performance characteristics than native SQL
239
+ # For large operations, consider using ArcadeDB's native SQL or Java API
240
+
241
+ # Add vertices
242
+ db.query("gremlin", "g.addV('Person').property('name', 'John').property('age', 30)", is_command=True)
243
+ db.query("gremlin", "g.addV('Person').property('name', 'Jane').property('age', 25)", is_command=True)
244
+
245
+ # Query with Gremlin
246
+ result = db.query("gremlin", "g.V().hasLabel('Person').values('name')")
247
+ print(result)
248
+
249
+ # Traversal
250
+ result = db.query("gremlin", "g.V().hasLabel('Person').has('age', gt(20)).values('name', 'age')")
251
+ print(result)
192
252
  ```
193
253
 
194
254
  ## Configuration Options
195
255
 
256
+ ### SyncClient Parameters
257
+
196
258
  | Parameter | Type | Default | Description |
197
259
  |-----------|------|---------|-------------|
198
260
  | `host` | str | "localhost" | ArcadeDB server hostname |
199
261
  | `port` | int | 2480 | ArcadeDB server port |
200
- | `username` | str | "root" | Database username |
262
+ | `username` | str | None | Database username |
201
263
  | `password` | str | None | Database password |
202
- | `database` | str | None | Database name |
203
- | `use_ssl` | bool | False | Enable SSL connection |
204
- | `timeout` | int | 30 | Request timeout in seconds |
205
- | `pool_size` | int | 10 | Connection pool size |
264
+ | `protocol` | str | "http" | Protocol ("http" or "https") |
265
+
266
+ ### DatabaseDao.query() Parameters
267
+
268
+ | Parameter | Type | Default | Description |
269
+ |-----------|------|---------|-------------|
270
+ | `language` | str | Required | Query language: "sql", "cypher", "gremlin", "graphql", "mongo" |
271
+ | `command` | str | Required | The query/command to execute |
272
+ | `is_command` | bool | False | Set True for DDL/DML (CREATE, INSERT, UPDATE, DELETE) |
273
+ | `limit` | int | None | Maximum number of results |
274
+ | `params` | dict | None | Query parameters |
275
+ | `session_id` | str | None | Transaction session ID |
206
276
 
207
277
  ## Requirements
208
278
 
209
- - **Python**: 3.8 or higher
210
- - **ArcadeDB**: Version 23.10 or higher
279
+ - **Python**: 3.10 or higher
280
+ - **ArcadeDB**: Version 25.8.1 or higher
211
281
  - **Dependencies**:
212
282
  - `requests` >= 2.25.0
213
283
  - `retry` >= 0.9.2