arcadedb-python 0.3.0__tar.gz → 0.4.0__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.4.0}/.gitignore +1 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/CHANGELOG.md +46 -0
- arcadedb_python-0.4.0/PKG-INFO +461 -0
- arcadedb_python-0.4.0/README.md +412 -0
- arcadedb_python-0.4.0/arcadedb_python/__init__.py +92 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/api/client.py +8 -2
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/api/config.py +1 -1
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/api/sync.py +6 -4
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/dao/database.py +181 -149
- arcadedb_python-0.4.0/arcadedb_python/logging_config.py +153 -0
- arcadedb_python-0.4.0/docs/API.md +719 -0
- arcadedb_python-0.4.0/docs/LOGGING.md +145 -0
- arcadedb_python-0.4.0/examples/quickstart_example.py +233 -0
- arcadedb_python-0.4.0/examples/test_query_languages.py +121 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/pyproject.toml +12 -3
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/test_enhanced_features.py +14 -10
- arcadedb_python-0.4.0/tests/test_integration_database.py +672 -0
- arcadedb_python-0.3.0/PKG-INFO +0 -344
- arcadedb_python-0.3.0/README.md +0 -295
- arcadedb_python-0.3.0/arcadedb_python/__init__.py +0 -62
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/LICENSE +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/api/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/dao/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/exceptions.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/model/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/model/database.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/arcadedb_python/model/request.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/api/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/api/test_client.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/api/test_config.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/model/__init__.py +0 -0
- {arcadedb_python-0.3.0 → arcadedb_python-0.4.0}/tests/model/test_request.py +0 -0
|
@@ -5,6 +5,52 @@ 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.4.0] - 2026-03-03
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Native openCypher engine**: use `"opencypher"` as the language — this targets ArcadeDB's native openCypher implementation; the old `"cypher"` identifier (Gremlin-based) is superseded
|
|
13
|
+
- **Vector index support**: `create_vector_index()` uses the new LSM_VECTOR / JVector index type; vector property type is `ARRAY_OF_FLOATS` (underscore form, per ArcadeDB manual; `LIST OF FLOAT` and `ARRAY OF FLOATS` are also valid); `vector_search()` uses `vectorNeighbors()` for top-k similarity search; `get_vector_similarity()` supports `vectorCosineSimilarity`, `vectorDotProduct`, `vectorL2Distance`
|
|
14
|
+
- **Logging**: per-module logging via `logging.getLogger(__name__)`; `configure_logging()` and `set_module_log_level()` utilities in `arcadedb_python.logging_config`
|
|
15
|
+
- **`sqlscript` language** added to `AVAILABLE_LANGUAGES` in `config.py`; `bulk_insert`, `bulk_upsert`, `bulk_delete` use it for multi-statement batches
|
|
16
|
+
- **Full live integration test suite** (`tests/test_integration_database.py`): 59 tests covering all public methods including transactions, bulk ops, vector ops, `get_records`, `get_triplets`, `safe_delete_all`, `safe_bulk_operation` (requires running ArcadeDB)
|
|
17
|
+
- **`docs/LOGGING.md`**: logging configuration guide
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- `bulk_insert`, `bulk_upsert`, `bulk_delete`: batch exceptions were silently swallowed when a prior batch had succeeded; they now always propagate immediately; per-batch success count also fixed to track failures per batch, not cumulatively
|
|
21
|
+
- `CREATE PROPERTY` with `IF NOT EXISTS` can cause `Type not found` errors in some contexts — avoid it inside `sqlscript`; use separate `sql` calls instead
|
|
22
|
+
- `cypher_formater`: robust fallback when pygments is unavailable; handles list and `$`-containing string params correctly
|
|
23
|
+
- Error response parsing improved in `sync.py` for non-JSON HTTP error bodies
|
|
24
|
+
- `get_triplets`: multi-strategy fallback (MATCH → edge traversal → per-type query) to handle varied ArcadeDB configurations
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `sync.py`: embedding arrays in log output are truncated to avoid cluttering logs
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [0.3.1] - 2025-10-21
|
|
31
|
+
|
|
32
|
+
**Bug fixes for 0.3.1, README.md now has correct Quick Start Code, docs/API.md added, examples added**
|
|
33
|
+
|
|
34
|
+
## Fixed
|
|
35
|
+
- 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
|
|
36
|
+
Was fixed in `dao/database.py` with different code for escaping parameters and property assignments.
|
|
37
|
+
- For bug #3 Quick Start: Basic Usage fails, the README.md quick start was updated to have the correct working code to upe
|
|
38
|
+
|
|
39
|
+
### Documentation
|
|
40
|
+
- 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
|
|
41
|
+
- Added `docs/API.md` documenting the classes and functions / parameters, 4 temp docs while developing removed
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- 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
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
- Updated `pyproject.toml` to have release 0.3.1
|
|
48
|
+
- `pyproject.toml`, `manifest.in`: docs and examples added to source release
|
|
49
|
+
- `client.py` headers() no content type logging level changed from warning to debug
|
|
50
|
+
- `sync.py` get() and post() logging level changed from info to debug (now won't see all sql calls by default),
|
|
51
|
+
- `__init__.py` updated to version 0.3.1
|
|
52
|
+
|
|
53
|
+
|
|
8
54
|
## [0.3.0] - 2025-09-23
|
|
9
55
|
|
|
10
56
|
**Major Enhancement Release for LlamaIndex Integration**
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arcadedb-python
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Python driver for ArcadeDB - Multi-Model Database with Graph, Document, Key-Value, Vector, and Time-Series support
|
|
5
|
+
Project-URL: Homepage, https://github.com/stevereiner/arcadedb-python
|
|
6
|
+
Project-URL: Documentation, https://docs.arcadedb.com/
|
|
7
|
+
Project-URL: Repository, https://github.com/stevereiner/arcadedb-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/stevereiner/arcadedb-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/stevereiner/arcadedb-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Steve Reiner, Adams Rosales, ExtReMLapin
|
|
11
|
+
Maintainer: Steve Reiner
|
|
12
|
+
License-Expression: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: arcadedb,database,document,graph,key-value,multi-model,nosql,python-driver,time-series,vector
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Database
|
|
25
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Requires-Dist: requests>=2.25.0
|
|
30
|
+
Requires-Dist: retry>=0.9.2
|
|
31
|
+
Provides-Extra: cypher
|
|
32
|
+
Requires-Dist: pygments>=2.0.0; extra == 'cypher'
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: flake8>=6.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: tox>=4.0.0; extra == 'dev'
|
|
43
|
+
Provides-Extra: full
|
|
44
|
+
Requires-Dist: psycopg>=3.0.0; extra == 'full'
|
|
45
|
+
Requires-Dist: pygments>=2.0.0; extra == 'full'
|
|
46
|
+
Provides-Extra: postgresql
|
|
47
|
+
Requires-Dist: psycopg>=3.0.0; extra == 'postgresql'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# ArcadeDB Python Driver
|
|
51
|
+
|
|
52
|
+
[](https://badge.fury.io/py/arcadedb-python)
|
|
53
|
+
[](https://pypi.org/project/arcadedb-python/)
|
|
54
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
55
|
+
|
|
56
|
+
A comprehensive Python driver for [ArcadeDB](https://arcadedb.com) - the Multi-Model Database that supports Graph, Document, Key-Value, Vector, and Time-Series models in a single engine. [Github for ArcadeDB](https://github.com/ArcadeData/arcadedb) (Apache 2.0).
|
|
57
|
+
|
|
58
|
+
> **Note:** This package connects to an **ArcadeDB server over REST/HTTP**. If you need to run ArcadeDB **embedded directly inside your Python application** (no separate server process), see [arcadedb-embedded-python](https://github.com/humemai/arcadedb-embedded-python) instead.
|
|
59
|
+
|
|
60
|
+
## Credits & Attribution
|
|
61
|
+
|
|
62
|
+
This driver builds upon the work of the original ArcadeDB Python driver contributors:
|
|
63
|
+
|
|
64
|
+
- **Adams Rosales** ([@adaros92](https://github.com/adaros92)) - Original [arcadedb-python-driver](https://github.com/adaros92/arcadedb-python-driver)
|
|
65
|
+
- **ExtReMLapin** ([@ExtReMLapin](https://github.com/ExtReMLapin)) - Core contributor and enhancements
|
|
66
|
+
|
|
67
|
+
This modernized version enhances the original work with updated packaging, documentation, tests, new APIs, vector support, etc.
|
|
68
|
+
|
|
69
|
+
## Features
|
|
70
|
+
|
|
71
|
+
- **Multi-Model Support**: Work with Graph, Document, Key-Value, Vector, and Time-Series data models
|
|
72
|
+
- **Full API Coverage**: Complete access to ArcadeDB's REST API with SQL, openCypher, Gremlin, GraphQL, and Mongo query languages
|
|
73
|
+
- **Vector Search**: Native LSM_VECTOR index support with `vectorNeighbors()` for AI/ML similarity search
|
|
74
|
+
- **Bulk Operations**: `bulk_insert`, `bulk_upsert`, `bulk_delete` using `sqlscript` for efficient batched writes
|
|
75
|
+
- **Type Annotations**: Type hints on all public methods for better IDE support
|
|
76
|
+
- **Comprehensive Testing**: Full integration test suite (59 tests) against a live ArcadeDB server
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
### Using UV (Recommended)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install uv if not already installed
|
|
84
|
+
pip install uv
|
|
85
|
+
|
|
86
|
+
# Create virtual environment and install
|
|
87
|
+
uv venv
|
|
88
|
+
uv pip install arcadedb-python
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Using Pip
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install arcadedb-python
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Optional Dependencies
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# PostgreSQL driver support
|
|
101
|
+
uv pip install arcadedb-python[postgresql]
|
|
102
|
+
# or: pip install arcadedb-python[postgresql]
|
|
103
|
+
|
|
104
|
+
# Cypher syntax highlighting
|
|
105
|
+
uv pip install arcadedb-python[cypher]
|
|
106
|
+
# or: pip install arcadedb-python[cypher]
|
|
107
|
+
|
|
108
|
+
# All optional features
|
|
109
|
+
uv pip install arcadedb-python[full]
|
|
110
|
+
# or: pip install arcadedb-python[full]
|
|
111
|
+
|
|
112
|
+
# Development dependencies
|
|
113
|
+
uv pip install arcadedb-python[dev]
|
|
114
|
+
# or: pip install arcadedb-python[dev]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
### Basic Usage
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from arcadedb_python import DatabaseDao, SyncClient
|
|
123
|
+
|
|
124
|
+
# Step 1: Create a client connection
|
|
125
|
+
client = SyncClient(
|
|
126
|
+
host="localhost",
|
|
127
|
+
port=2480,
|
|
128
|
+
username="root",
|
|
129
|
+
password="playwithdata"
|
|
130
|
+
)
|
|
131
|
+
|
|
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)
|
|
140
|
+
|
|
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)
|
|
147
|
+
|
|
148
|
+
# Step 6: Graph traversal
|
|
149
|
+
result = db.query("sql", """
|
|
150
|
+
MATCH {type: Person, as: person}
|
|
151
|
+
RETURN person.name, person.age
|
|
152
|
+
""")
|
|
153
|
+
print(result)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Important Notes
|
|
157
|
+
|
|
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
|
+
- **`IF NOT EXISTS`** is supported for `DOCUMENT TYPE`, `VERTEX TYPE`, and `EDGE TYPE`
|
|
162
|
+
|
|
163
|
+
## API Documentation
|
|
164
|
+
|
|
165
|
+
For complete API reference including all methods, parameters, exceptions, and detailed examples:
|
|
166
|
+
|
|
167
|
+
**📚 [docs/API.md](docs/API.md)** - Comprehensive API documentation covering:
|
|
168
|
+
- `SyncClient` - Connection management
|
|
169
|
+
- `DatabaseDao` - All database operations (query, transactions, bulk operations)
|
|
170
|
+
- Exception handling and error types
|
|
171
|
+
- Configuration options
|
|
172
|
+
- Complete code examples
|
|
173
|
+
|
|
174
|
+
## Examples
|
|
175
|
+
|
|
176
|
+
### Available Examples
|
|
177
|
+
|
|
178
|
+
**[examples/quickstart_example.py](examples/quickstart_example.py)**
|
|
179
|
+
- Complete walkthrough of all Quick Start code
|
|
180
|
+
- All data models: Graph, Document, Key-Value, Time-Series, Vector storage
|
|
181
|
+
- Step-by-step explanations
|
|
182
|
+
- Error handling examples
|
|
183
|
+
|
|
184
|
+
**[examples/test_query_languages.py](examples/test_query_languages.py)**
|
|
185
|
+
- openCypher query examples
|
|
186
|
+
- Gremlin query examples
|
|
187
|
+
- Database creation and cleanup
|
|
188
|
+
|
|
189
|
+
### Running Examples
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Complete quickstart with all features
|
|
193
|
+
python examples/quickstart_example.py
|
|
194
|
+
|
|
195
|
+
# Test openCypher and Gremlin queries
|
|
196
|
+
python examples/test_query_languages.py
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Requirements:** ArcadeDB must be running on `localhost:2480` with default credentials (`root`/`playwithdata`)
|
|
200
|
+
|
|
201
|
+
## Advanced Usage
|
|
202
|
+
|
|
203
|
+
### Document Operations
|
|
204
|
+
|
|
205
|
+
Documents are schema-flexible records. They cannot be endpoints of edges.
|
|
206
|
+
Vertices are documents with added capability: they can be connected by edges.
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
db.query("sql", "CREATE DOCUMENT TYPE Product IF NOT EXISTS", is_command=True)
|
|
210
|
+
db.query("sql", """
|
|
211
|
+
INSERT INTO Product CONTENT {
|
|
212
|
+
"name": "Laptop",
|
|
213
|
+
"price": 999.99,
|
|
214
|
+
"specs": {
|
|
215
|
+
"cpu": "Intel i7",
|
|
216
|
+
"ram": "16GB"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
""", is_command=True)
|
|
220
|
+
|
|
221
|
+
result = db.query("sql", "SELECT FROM Product")
|
|
222
|
+
print(result)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Graph Operations
|
|
226
|
+
|
|
227
|
+
Edges connect **vertex** types only. Both the source and target must be `VERTEX TYPE`.
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
# Create vertex types for both ends of the edge
|
|
231
|
+
db.query("sql", "CREATE VERTEX TYPE Customer IF NOT EXISTS", is_command=True)
|
|
232
|
+
db.query("sql", "CREATE VERTEX TYPE ItemType IF NOT EXISTS", is_command=True)
|
|
233
|
+
db.query("sql", "CREATE EDGE TYPE Purchased IF NOT EXISTS", is_command=True)
|
|
234
|
+
|
|
235
|
+
# Insert vertices
|
|
236
|
+
db.query("sql", "INSERT INTO Customer SET name = 'Alice'", is_command=True)
|
|
237
|
+
db.query("sql", "INSERT INTO ItemType SET name = 'Laptop', price = 999.99", is_command=True)
|
|
238
|
+
|
|
239
|
+
# Connect them with an edge
|
|
240
|
+
db.query("sql", """
|
|
241
|
+
CREATE EDGE Purchased
|
|
242
|
+
FROM (SELECT FROM Customer WHERE name = 'Alice')
|
|
243
|
+
TO (SELECT FROM ItemType WHERE name = 'Laptop')
|
|
244
|
+
SET date = sysdate(), amount = 999.99
|
|
245
|
+
""", is_command=True)
|
|
246
|
+
|
|
247
|
+
# Traverse the graph
|
|
248
|
+
result = db.query("sql", """
|
|
249
|
+
SELECT expand(out('Purchased')) FROM Customer WHERE name = 'Alice'
|
|
250
|
+
""")
|
|
251
|
+
print(result)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Key-Value Operations
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
db.query("sql", "CREATE DOCUMENT TYPE Settings IF NOT EXISTS", is_command=True)
|
|
258
|
+
db.query("sql", "INSERT INTO Settings SET key = 'theme', value = 'dark'", is_command=True)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Time-Series Operations
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
db.query("sql", "CREATE VERTEX TYPE Sensor IF NOT EXISTS", is_command=True)
|
|
265
|
+
db.query("sql", """
|
|
266
|
+
INSERT INTO Sensor SET
|
|
267
|
+
sensor_id = 'temp_01',
|
|
268
|
+
timestamp = sysdate(),
|
|
269
|
+
temperature = 23.5
|
|
270
|
+
""", is_command=True)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Vector Search (for AI/ML applications)
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
# Declare the vector property and create an LSM vector index
|
|
277
|
+
db.query("sql", "CREATE VERTEX TYPE DocRecord", is_command=True)
|
|
278
|
+
db.query("sql", "CREATE PROPERTY DocRecord.embedding ARRAY_OF_FLOATS", is_command=True)
|
|
279
|
+
db.create_vector_index("DocRecord", "embedding", dimensions=4)
|
|
280
|
+
|
|
281
|
+
# Insert documents with embeddings (use CONTENT for structured inserts)
|
|
282
|
+
db.query("sql", """
|
|
283
|
+
INSERT INTO DocRecord CONTENT {
|
|
284
|
+
"title": "AI Research Paper",
|
|
285
|
+
"embedding": [0.1, 0.2, 0.3, 0.4],
|
|
286
|
+
"content": "Full document text..."
|
|
287
|
+
}
|
|
288
|
+
""", is_command=True)
|
|
289
|
+
db.query("sql", """
|
|
290
|
+
INSERT INTO DocRecord CONTENT {
|
|
291
|
+
"title": "Machine Learning Guide",
|
|
292
|
+
"embedding": [0.9, 0.8, 0.7, 0.6],
|
|
293
|
+
"content": "Intro to ML..."
|
|
294
|
+
}
|
|
295
|
+
""", is_command=True)
|
|
296
|
+
|
|
297
|
+
# Perform vector similarity search
|
|
298
|
+
results = db.vector_search(
|
|
299
|
+
type_name="DocRecord",
|
|
300
|
+
embedding_field="embedding",
|
|
301
|
+
query_embedding=[0.1, 0.2, 0.3, 0.4],
|
|
302
|
+
top_k=2
|
|
303
|
+
)
|
|
304
|
+
for doc in results:
|
|
305
|
+
print(doc["title"])
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Using openCypher
|
|
309
|
+
|
|
310
|
+
> **Note:** Use `"opencypher"` as the language to target ArcadeDB's native openCypher engine,
|
|
311
|
+
> introduced in recent releases. The older `"cypher"` language identifier used a Cypher
|
|
312
|
+
> implementation built on top of Gremlin and is now superseded by this native engine.
|
|
313
|
+
|
|
314
|
+
```python
|
|
315
|
+
|
|
316
|
+
# Create nodes
|
|
317
|
+
db.query("opencypher", "CREATE (p:Person {name: 'John', age: 30})", is_command=True)
|
|
318
|
+
db.query("opencypher", "CREATE (p:Person {name: 'Jane', age: 25})", is_command=True)
|
|
319
|
+
|
|
320
|
+
# Create relationship
|
|
321
|
+
db.query("opencypher", """
|
|
322
|
+
MATCH (a:Person {name: 'John'}), (b:Person {name: 'Jane'})
|
|
323
|
+
CREATE (a)-[:KNOWS]->(b)
|
|
324
|
+
""", is_command=True)
|
|
325
|
+
|
|
326
|
+
# Query with openCypher
|
|
327
|
+
result = db.query("opencypher", "MATCH (p:Person) RETURN p.name, p.age")
|
|
328
|
+
print(result)
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Using Gremlin
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
# Note: Gremlin support may have different performance characteristics than native SQL
|
|
335
|
+
# For large operations, consider using ArcadeDB's native SQL or Java API
|
|
336
|
+
|
|
337
|
+
# Add vertices
|
|
338
|
+
db.query("gremlin", "g.addV('Person').property('name', 'John').property('age', 30)", is_command=True)
|
|
339
|
+
db.query("gremlin", "g.addV('Person').property('name', 'Jane').property('age', 25)", is_command=True)
|
|
340
|
+
|
|
341
|
+
# Query with Gremlin
|
|
342
|
+
result = db.query("gremlin", "g.V().hasLabel('Person').values('name')")
|
|
343
|
+
print(result)
|
|
344
|
+
|
|
345
|
+
# Traversal
|
|
346
|
+
result = db.query("gremlin", "g.V().hasLabel('Person').has('age', gt(20)).values('name', 'age')")
|
|
347
|
+
print(result)
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Configuration Options
|
|
351
|
+
|
|
352
|
+
### SyncClient Parameters
|
|
353
|
+
|
|
354
|
+
| Parameter | Type | Default | Description |
|
|
355
|
+
|-----------|------|---------|-------------|
|
|
356
|
+
| `host` | str | "localhost" | ArcadeDB server hostname |
|
|
357
|
+
| `port` | int | 2480 | ArcadeDB server port |
|
|
358
|
+
| `username` | str | None | Database username |
|
|
359
|
+
| `password` | str | None | Database password |
|
|
360
|
+
| `protocol` | str | "http" | Protocol ("http" or "https") |
|
|
361
|
+
|
|
362
|
+
### DatabaseDao.query() Parameters
|
|
363
|
+
|
|
364
|
+
| Parameter | Type | Default | Description |
|
|
365
|
+
|-----------|------|---------|-------------|
|
|
366
|
+
| `language` | str | Required | Query language: "sql", "opencypher", "gremlin", "graphql", "mongo" |
|
|
367
|
+
| `command` | str | Required | The query/command to execute |
|
|
368
|
+
| `is_command` | bool | False | Set True for DDL/DML (CREATE, INSERT, UPDATE, DELETE) |
|
|
369
|
+
| `limit` | int | None | Maximum number of results |
|
|
370
|
+
| `params` | dict | None | Query parameters |
|
|
371
|
+
| `session_id` | str | None | Transaction session ID |
|
|
372
|
+
|
|
373
|
+
## Requirements
|
|
374
|
+
|
|
375
|
+
- **Python**: 3.10 or higher
|
|
376
|
+
- **ArcadeDB**: Version 25.8.1 or higher
|
|
377
|
+
- **Dependencies**:
|
|
378
|
+
- `requests` >= 2.25.0
|
|
379
|
+
- `retry` >= 0.9.2
|
|
380
|
+
|
|
381
|
+
## Development
|
|
382
|
+
|
|
383
|
+
### Setting up Development Environment
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
# Clone the repository
|
|
387
|
+
git clone https://github.com/stevereiner/arcadedb-python.git
|
|
388
|
+
cd arcadedb-python
|
|
389
|
+
|
|
390
|
+
# Install uv (if not already installed)
|
|
391
|
+
pip install uv
|
|
392
|
+
|
|
393
|
+
# Create virtual environment and install dependencies
|
|
394
|
+
uv venv
|
|
395
|
+
uv pip install -e .[dev]
|
|
396
|
+
|
|
397
|
+
# Run tests
|
|
398
|
+
uv run pytest
|
|
399
|
+
|
|
400
|
+
# Run linting
|
|
401
|
+
uv run black .
|
|
402
|
+
uv run isort .
|
|
403
|
+
uv run flake8
|
|
404
|
+
uv run mypy arcadedb_python
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Building the Package
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Build the package
|
|
411
|
+
uv build
|
|
412
|
+
|
|
413
|
+
# Check the built package
|
|
414
|
+
uv run twine check dist/*
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Running ArcadeDB for Development
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# Using Docker
|
|
421
|
+
docker run -d --name arcadedb \
|
|
422
|
+
-p 2480:2480 -p 2424:2424 \
|
|
423
|
+
-e JAVA_OPTS="-Darcadedb.server.rootPassword=playwithdata" \
|
|
424
|
+
arcadedata/arcadedb:latest
|
|
425
|
+
|
|
426
|
+
# Access ArcadeDB Studio at http://localhost:2480
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Contributing
|
|
430
|
+
|
|
431
|
+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
|
|
432
|
+
|
|
433
|
+
1. Fork the repository
|
|
434
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
435
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
436
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
437
|
+
5. Open a Pull Request
|
|
438
|
+
|
|
439
|
+
## License
|
|
440
|
+
|
|
441
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
442
|
+
|
|
443
|
+
## Links
|
|
444
|
+
|
|
445
|
+
### This Project
|
|
446
|
+
- **GitHub**: https://github.com/stevereiner/arcadedb-python
|
|
447
|
+
- **PyPI**: https://pypi.org/project/arcadedb-python/
|
|
448
|
+
- **Issues**: https://github.com/stevereiner/arcadedb-python/issues
|
|
449
|
+
|
|
450
|
+
### ArcadeDB
|
|
451
|
+
- **Homepage**: https://arcadedb.com
|
|
452
|
+
- **Documentation**: https://docs.arcadedb.com
|
|
453
|
+
- **Main Repository**: https://github.com/ArcadeData/arcadedb
|
|
454
|
+
|
|
455
|
+
### Original Contributors
|
|
456
|
+
- **Adams Rosales**: https://github.com/adaros92/arcadedb-python-driver
|
|
457
|
+
- **ExtReMLapin**: https://github.com/ExtReMLapin
|
|
458
|
+
|
|
459
|
+
## Changelog
|
|
460
|
+
|
|
461
|
+
See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes.
|