arcadedb-python 0.3.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.
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/CHANGELOG.md +25 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/PKG-INFO +137 -67
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/README.md +136 -66
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/__init__.py +26 -6
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/api/client.py +1 -1
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/api/sync.py +2 -2
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/dao/database.py +17 -13
- arcadedb_python-0.3.1/docs/API.md +719 -0
- arcadedb_python-0.3.1/examples/quickstart_example.py +210 -0
- arcadedb_python-0.3.1/examples/test_query_languages.py +121 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/pyproject.toml +11 -2
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/.gitignore +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/LICENSE +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/api/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/api/config.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/dao/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/exceptions.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/model/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/model/database.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/arcadedb_python/model/request.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/api/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/api/test_client.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/api/test_config.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/model/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/model/test_request.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.3.1}/tests/test_enhanced_features.py +0 -0
|
@@ -5,6 +5,31 @@ 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
|
+
|
|
8
33
|
## [0.3.0] - 2025-09-23
|
|
9
34
|
|
|
10
35
|
**Major Enhancement Release for LlamaIndex Integration**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: arcadedb-python
|
|
3
|
-
Version: 0.3.
|
|
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
|
-
#
|
|
125
|
-
|
|
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
|
-
#
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
#
|
|
138
|
-
db.
|
|
139
|
-
|
|
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
|
-
###
|
|
156
|
+
### Important Notes
|
|
149
157
|
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
154
|
-
config = ArcadeDBConfig(
|
|
155
|
-
host="localhost",
|
|
156
|
-
port=2480,
|
|
157
|
-
username="root",
|
|
158
|
-
password="playwithdata"
|
|
159
|
-
)
|
|
164
|
+
## API Documentation
|
|
160
165
|
|
|
161
|
-
|
|
162
|
-
```
|
|
166
|
+
For complete API reference including all methods, parameters, exceptions, and detailed examples:
|
|
163
167
|
|
|
164
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
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.
|
|
187
|
-
db.
|
|
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.
|
|
200
|
-
db.
|
|
201
|
-
db.
|
|
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 =
|
|
206
|
-
""")
|
|
227
|
+
SET date = sysdate(), amount = 999.99
|
|
228
|
+
""", is_command=True)
|
|
207
229
|
|
|
208
230
|
# Key-Value operations
|
|
209
|
-
db.
|
|
210
|
-
db.
|
|
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.
|
|
214
|
-
db.
|
|
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.
|
|
227
|
-
|
|
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,
|
|
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
|
-
#
|
|
234
|
-
result = db.query("sql", ""
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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 |
|
|
311
|
+
| `username` | str | None | Database username |
|
|
250
312
|
| `password` | str | None | Database password |
|
|
251
|
-
| `
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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.
|
|
259
|
-
- **ArcadeDB**: Version
|
|
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
|
-
#
|
|
76
|
-
|
|
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
|
-
#
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
#
|
|
89
|
-
db.
|
|
90
|
-
|
|
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
|
-
###
|
|
107
|
+
### Important Notes
|
|
100
108
|
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
105
|
-
config = ArcadeDBConfig(
|
|
106
|
-
host="localhost",
|
|
107
|
-
port=2480,
|
|
108
|
-
username="root",
|
|
109
|
-
password="playwithdata"
|
|
110
|
-
)
|
|
115
|
+
## API Documentation
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
```
|
|
117
|
+
For complete API reference including all methods, parameters, exceptions, and detailed examples:
|
|
114
118
|
|
|
115
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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.
|
|
138
|
-
db.
|
|
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.
|
|
151
|
-
db.
|
|
152
|
-
db.
|
|
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 =
|
|
157
|
-
""")
|
|
178
|
+
SET date = sysdate(), amount = 999.99
|
|
179
|
+
""", is_command=True)
|
|
158
180
|
|
|
159
181
|
# Key-Value operations
|
|
160
|
-
db.
|
|
161
|
-
db.
|
|
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.
|
|
165
|
-
db.
|
|
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.
|
|
178
|
-
|
|
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,
|
|
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
|
-
#
|
|
185
|
-
result = db.query("sql", ""
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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 |
|
|
262
|
+
| `username` | str | None | Database username |
|
|
201
263
|
| `password` | str | None | Database password |
|
|
202
|
-
| `
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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.
|
|
210
|
-
- **ArcadeDB**: Version
|
|
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
|
|
@@ -9,19 +9,37 @@ developers to work with all of ArcadeDB's data models through a unified API.
|
|
|
9
9
|
Example:
|
|
10
10
|
Basic usage:
|
|
11
11
|
|
|
12
|
-
>>> from arcadedb_python import DatabaseDao
|
|
13
|
-
>>>
|
|
14
|
-
>>>
|
|
12
|
+
>>> from arcadedb_python import DatabaseDao, SyncClient
|
|
13
|
+
>>> client = SyncClient("localhost", 2480, username="root", password="playwithdata")
|
|
14
|
+
>>> db = DatabaseDao(client, "mydb")
|
|
15
|
+
>>> result = db.query("sql", "SELECT FROM Person LIMIT 10")
|
|
15
16
|
>>> print(result)
|
|
16
17
|
|
|
17
18
|
Classes:
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
SyncClient: HTTP client for connecting to ArcadeDB
|
|
20
|
+
DatabaseDao: Main database access object for executing queries and commands
|
|
21
|
+
Client: Abstract base class for database clients
|
|
22
|
+
|
|
23
|
+
Constants:
|
|
24
|
+
AVAILABLE_LANGUAGES: Set of supported query languages
|
|
25
|
+
{"sql", "sqlscript", "graphql", "cypher", "gremlin", "mongo"}
|
|
26
|
+
|
|
27
|
+
Exceptions:
|
|
28
|
+
ArcadeDBException: Base exception class
|
|
29
|
+
LoginFailedException: Authentication failure
|
|
30
|
+
QueryParsingException: Query syntax error
|
|
31
|
+
TransactionException: Transaction error
|
|
32
|
+
SchemaException: Schema-related error
|
|
33
|
+
DatabaseException: Database operation error
|
|
34
|
+
ConnectionException: Connection error
|
|
35
|
+
ValidationException: Input validation error
|
|
36
|
+
BulkOperationException: Bulk operation error
|
|
37
|
+
VectorOperationException: Vector operation error
|
|
20
38
|
|
|
21
39
|
For more information, visit: https://docs.arcadedb.com/
|
|
22
40
|
"""
|
|
23
41
|
|
|
24
|
-
__version__ = "0.3.
|
|
42
|
+
__version__ = "0.3.1"
|
|
25
43
|
__author__ = "Adams Rosales, ExtReMLapin, Steve Reiner"
|
|
26
44
|
__email__ = ""
|
|
27
45
|
__license__ = "Apache-2.0"
|
|
@@ -30,6 +48,7 @@ __license__ = "Apache-2.0"
|
|
|
30
48
|
from arcadedb_python.dao.database import DatabaseDao
|
|
31
49
|
from arcadedb_python.api.sync import SyncClient
|
|
32
50
|
from arcadedb_python.api.client import Client
|
|
51
|
+
from arcadedb_python.api.config import AVAILABLE_LANGUAGES
|
|
33
52
|
from arcadedb_python.exceptions import (
|
|
34
53
|
ArcadeDBException,
|
|
35
54
|
LoginFailedException,
|
|
@@ -47,6 +66,7 @@ __all__ = [
|
|
|
47
66
|
"DatabaseDao",
|
|
48
67
|
"SyncClient",
|
|
49
68
|
"Client",
|
|
69
|
+
"AVAILABLE_LANGUAGES",
|
|
50
70
|
# Exceptions
|
|
51
71
|
"ArcadeDBException",
|
|
52
72
|
"LoginFailedException",
|
|
@@ -49,7 +49,7 @@ class Client(ABC):
|
|
|
49
49
|
default = "application/json"
|
|
50
50
|
key = "content_type"
|
|
51
51
|
if key not in self.kwargs:
|
|
52
|
-
logging.
|
|
52
|
+
logging.debug(f"No content type specified, using default: {default}")
|
|
53
53
|
content_type = self.kwargs.get(key, default)
|
|
54
54
|
return {"Content-Type": content_type}
|
|
55
55
|
|