matrixone-python-sdk 0.1.12__tar.gz → 0.1.14__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.
- {matrixone_python_sdk-0.1.12/matrixone_python_sdk.egg-info → matrixone_python_sdk-0.1.14}/PKG-INFO +11 -1
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/README.md +6 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/README_USER.md +10 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_08_pubsub_operations.py +20 -40
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_13_vector_indexes.py +2 -4
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_18_snapshot_orm.py +10 -20
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_22_unified_sql_builder.py +12 -24
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_29_complex_queries.py +8 -16
- matrixone_python_sdk-0.1.14/examples/example_32_branch_operations.py +477 -0
- matrixone_python_sdk-0.1.14/examples/example_33_ivf_rank_search.py +385 -0
- matrixone_python_sdk-0.1.14/examples/example_34_branch_diff_count.py +317 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_dynamic_logging.py +8 -16
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/__init__.py +9 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/async_client.py +47 -0
- matrixone_python_sdk-0.1.14/matrixone/branch.py +907 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/client.py +58 -4
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/clone.py +4 -4
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/exceptions.py +4 -0
- matrixone_python_sdk-0.1.14/matrixone/ivf_rank.py +125 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/pitr.py +16 -16
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/restore.py +8 -12
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/session.py +4 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/snapshot.py +6 -6
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/dialect.py +15 -20
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/fulltext_index.py +38 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/vector_manager.py +239 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/version.py +12 -2
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14/matrixone_python_sdk.egg-info}/PKG-INFO +11 -1
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/SOURCES.txt +5 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/pyproject.toml +1 -1
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/LICENSE +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/MANIFEST.in +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_01_basic_connection.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_02_account_management.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_03_async_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_04_transaction_management.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_05_snapshot_restore.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_06_sqlalchemy_integration.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_07_advanced_features.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_09_logger_integration.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_10_version_management.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_11_matrixone_version_demo.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_12_vector_basics.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_14_vector_search.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_15_vector_advanced.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_19_sqlalchemy_style_orm.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_20_sqlalchemy_engine_integration.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_21_advanced_orm_features.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_23_load_data_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_24_query_update.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_25_metadata_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_26_stage_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_27_export_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_28_sqlalchemy_select.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_30_with_snapshot_method.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_31_cdc_operations.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_connection_hooks.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_ivf_stats_complete.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/account.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/async_orm.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/base_client.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/cdc.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/cli_tools.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/config.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/connection_hooks.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/export.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/fulltext_manager.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/index_utils.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/load_data.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/logger.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/metadata.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/moctl.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/orm.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/pubsub.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/search_vector_index.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sql_builder.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/__init__.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/fulltext_search.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/hnsw_config.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/ivf_config.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/json_functions.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/json_type.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/snapshot.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/table_builder.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/vector_index.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_ext/vector_type.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/sqlalchemy_select.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone/stage.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/dependency_links.txt +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/entry_points.txt +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/not-zip-safe +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/requires.txt +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/matrixone_python_sdk.egg-info/top_level.txt +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/mo_diag.py +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/requirements.txt +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/setup.cfg +0 -0
- {matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/setup.py +0 -0
{matrixone_python_sdk-0.1.12/matrixone_python_sdk.egg-info → matrixone_python_sdk-0.1.14}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: matrixone-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: A comprehensive Python SDK for MatrixOne database operations with vector search, fulltext search, and advanced features
|
|
5
5
|
Home-page: https://github.com/matrixorigin/matrixone
|
|
6
6
|
Author: MatrixOne Team
|
|
@@ -87,6 +87,9 @@ A comprehensive, high-level Python SDK for MatrixOne that provides SQLAlchemy-li
|
|
|
87
87
|
- 📋 [Best Practices](https://matrixone.readthedocs.io/en/latest/best_practices.html)
|
|
88
88
|
- 📖 [API Reference](https://matrixone.readthedocs.io/en/latest/api/index.html)
|
|
89
89
|
|
|
90
|
+
**For Developers:**
|
|
91
|
+
- 🛠️ [MatrixOne Development Guide](../../etc/DEV_README.md) - Complete guide for setting up MatrixOne locally, multi-CN clusters, monitoring, and all `make dev-*` commands
|
|
92
|
+
|
|
90
93
|
---
|
|
91
94
|
|
|
92
95
|
## ✨ Features
|
|
@@ -205,6 +208,13 @@ class User(Base):
|
|
|
205
208
|
|
|
206
209
|
## Quick Start
|
|
207
210
|
|
|
211
|
+
> **💡 Need to set up MatrixOne server?**
|
|
212
|
+
> If you don't have MatrixOne running yet, check out the [MatrixOne Development Guide](../../etc/DEV_README.md) for instructions on:
|
|
213
|
+
> - Starting a standalone MatrixOne instance
|
|
214
|
+
> - Setting up a multi-CN cluster with Docker Compose
|
|
215
|
+
> - Enabling monitoring and metrics
|
|
216
|
+
> - All `make dev-*` commands
|
|
217
|
+
|
|
208
218
|
### Basic Usage
|
|
209
219
|
|
|
210
220
|
```python
|
|
@@ -22,6 +22,7 @@ A comprehensive Python SDK for MatrixOne that provides SQLAlchemy-like interface
|
|
|
22
22
|
- Support for f32 and f64 precision vectors
|
|
23
23
|
- Multiple distance metrics (L2, Cosine, Inner Product)
|
|
24
24
|
- ⭐ **IVF Index Health Monitoring** with `get_ivf_stats()` - Critical for production!
|
|
25
|
+
- ⭐ **IVF LIMIT BY RANK** - Fine-grained ranking control (pre/post/force modes)
|
|
25
26
|
- Configurable index parameters for performance tuning
|
|
26
27
|
- 🔍 **Fulltext Search**: Powerful fulltext indexing and search with BM25 and TF-IDF algorithms
|
|
27
28
|
- Natural language and boolean search modes
|
|
@@ -55,6 +56,11 @@ A comprehensive Python SDK for MatrixOne that provides SQLAlchemy-like interface
|
|
|
55
56
|
- 📸 **Snapshot Management**: Create and manage database snapshots at multiple levels
|
|
56
57
|
- ⏰ **Point-in-Time Recovery**: PITR functionality for precise data recovery
|
|
57
58
|
- 🔄 **Table Cloning**: Clone databases and tables efficiently with data replication
|
|
59
|
+
- 🌿 **Branch Management**: Git-style version control for databases and tables
|
|
60
|
+
- Create isolated branches for development and testing
|
|
61
|
+
- Compare differences between branches with count-only optimization
|
|
62
|
+
- Merge branches with conflict resolution strategies
|
|
63
|
+
- Point-in-time branching from snapshots
|
|
58
64
|
- 👥 **Account Management**: Comprehensive user, role, and permission management
|
|
59
65
|
- 📊 **Pub/Sub**: Real-time publication and subscription support
|
|
60
66
|
- 🔧 **Version Management**: Automatic backend version detection and compatibility checking
|
|
@@ -19,6 +19,9 @@ A comprehensive, high-level Python SDK for MatrixOne that provides SQLAlchemy-li
|
|
|
19
19
|
- 📋 [Best Practices](https://matrixone.readthedocs.io/en/latest/best_practices.html)
|
|
20
20
|
- 📖 [API Reference](https://matrixone.readthedocs.io/en/latest/api/index.html)
|
|
21
21
|
|
|
22
|
+
**For Developers:**
|
|
23
|
+
- 🛠️ [MatrixOne Development Guide](../../etc/DEV_README.md) - Complete guide for setting up MatrixOne locally, multi-CN clusters, monitoring, and all `make dev-*` commands
|
|
24
|
+
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
## ✨ Features
|
|
@@ -137,6 +140,13 @@ class User(Base):
|
|
|
137
140
|
|
|
138
141
|
## Quick Start
|
|
139
142
|
|
|
143
|
+
> **💡 Need to set up MatrixOne server?**
|
|
144
|
+
> If you don't have MatrixOne running yet, check out the [MatrixOne Development Guide](../../etc/DEV_README.md) for instructions on:
|
|
145
|
+
> - Starting a standalone MatrixOne instance
|
|
146
|
+
> - Setting up a multi-CN cluster with Docker Compose
|
|
147
|
+
> - Enabling monitoring and metrics
|
|
148
|
+
> - All `make dev-*` commands
|
|
149
|
+
|
|
140
150
|
### Basic Usage
|
|
141
151
|
|
|
142
152
|
```python
|
{matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_08_pubsub_operations.py
RENAMED
|
@@ -219,8 +219,7 @@ def demo_cross_account_pubsub():
|
|
|
219
219
|
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="publisher_data"
|
|
220
220
|
)
|
|
221
221
|
|
|
222
|
-
pub_admin_client.execute(
|
|
223
|
-
"""
|
|
222
|
+
pub_admin_client.execute("""
|
|
224
223
|
CREATE TABLE IF NOT EXISTS sales_data (
|
|
225
224
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
226
225
|
product_name VARCHAR(100) NOT NULL,
|
|
@@ -228,11 +227,9 @@ def demo_cross_account_pubsub():
|
|
|
228
227
|
price DECIMAL(10,2),
|
|
229
228
|
sale_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
230
229
|
)
|
|
231
|
-
"""
|
|
232
|
-
)
|
|
230
|
+
""")
|
|
233
231
|
|
|
234
|
-
pub_admin_client.execute(
|
|
235
|
-
"""
|
|
232
|
+
pub_admin_client.execute("""
|
|
236
233
|
CREATE TABLE IF NOT EXISTS customer_data (
|
|
237
234
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
238
235
|
customer_name VARCHAR(100) NOT NULL,
|
|
@@ -240,8 +237,7 @@ def demo_cross_account_pubsub():
|
|
|
240
237
|
phone VARCHAR(20),
|
|
241
238
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
242
239
|
)
|
|
243
|
-
"""
|
|
244
|
-
)
|
|
240
|
+
""")
|
|
245
241
|
|
|
246
242
|
# Insert sample data
|
|
247
243
|
pub_admin_client.execute("DELETE FROM sales_data")
|
|
@@ -323,14 +319,12 @@ def demo_cross_account_pubsub():
|
|
|
323
319
|
logger.info(f" 📊 Total sales records: {sales_count}")
|
|
324
320
|
|
|
325
321
|
# Show sales summary
|
|
326
|
-
result = pub_admin_client.execute(
|
|
327
|
-
"""
|
|
322
|
+
result = pub_admin_client.execute("""
|
|
328
323
|
SELECT product_name, SUM(quantity) as total_qty, SUM(quantity * price) as total_value
|
|
329
324
|
FROM sales_data
|
|
330
325
|
GROUP BY product_name
|
|
331
326
|
ORDER BY total_value DESC
|
|
332
|
-
"""
|
|
333
|
-
)
|
|
327
|
+
""")
|
|
334
328
|
logger.info(" 📋 Sales summary:")
|
|
335
329
|
for row in result.rows:
|
|
336
330
|
logger.info(f" - {row[0]}: {row[1]} units, ${row[2]:.2f}")
|
|
@@ -398,8 +392,7 @@ async def demo_async_pubsub_operations():
|
|
|
398
392
|
await client.execute("CREATE DATABASE IF NOT EXISTS async_pubsub_test")
|
|
399
393
|
await client.execute("USE async_pubsub_test")
|
|
400
394
|
|
|
401
|
-
await client.execute(
|
|
402
|
-
"""
|
|
395
|
+
await client.execute("""
|
|
403
396
|
CREATE TABLE IF NOT EXISTS events (
|
|
404
397
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
405
398
|
event_type VARCHAR(50) NOT NULL,
|
|
@@ -407,8 +400,7 @@ async def demo_async_pubsub_operations():
|
|
|
407
400
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
408
401
|
source VARCHAR(100)
|
|
409
402
|
)
|
|
410
|
-
"""
|
|
411
|
-
)
|
|
403
|
+
""")
|
|
412
404
|
|
|
413
405
|
# Insert sample data
|
|
414
406
|
await client.execute("DELETE FROM events")
|
|
@@ -474,14 +466,12 @@ async def demo_async_pubsub_operations():
|
|
|
474
466
|
logger.info(f" 📊 Total events: {event_count}")
|
|
475
467
|
|
|
476
468
|
# Show event distribution by type
|
|
477
|
-
result = await client.execute(
|
|
478
|
-
"""
|
|
469
|
+
result = await client.execute("""
|
|
479
470
|
SELECT event_type, COUNT(*) as count
|
|
480
471
|
FROM events
|
|
481
472
|
GROUP BY event_type
|
|
482
473
|
ORDER BY count DESC
|
|
483
|
-
"""
|
|
484
|
-
)
|
|
474
|
+
""")
|
|
485
475
|
logger.info(" 📊 Event distribution by type:")
|
|
486
476
|
for row in result.rows:
|
|
487
477
|
logger.info(f" - {row[0]}: {row[1]} events")
|
|
@@ -520,8 +510,7 @@ def demo_pubsub_best_practices():
|
|
|
520
510
|
client.execute("USE ecommerce")
|
|
521
511
|
|
|
522
512
|
# Create tables
|
|
523
|
-
client.execute(
|
|
524
|
-
"""
|
|
513
|
+
client.execute("""
|
|
525
514
|
CREATE TABLE IF NOT EXISTS products (
|
|
526
515
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
527
516
|
name VARCHAR(100) NOT NULL,
|
|
@@ -530,11 +519,9 @@ def demo_pubsub_best_practices():
|
|
|
530
519
|
category VARCHAR(50),
|
|
531
520
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
532
521
|
)
|
|
533
|
-
"""
|
|
534
|
-
)
|
|
522
|
+
""")
|
|
535
523
|
|
|
536
|
-
client.execute(
|
|
537
|
-
"""
|
|
524
|
+
client.execute("""
|
|
538
525
|
CREATE TABLE IF NOT EXISTS orders (
|
|
539
526
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
540
527
|
customer_id INT,
|
|
@@ -544,11 +531,9 @@ def demo_pubsub_best_practices():
|
|
|
544
531
|
status VARCHAR(20) DEFAULT 'pending',
|
|
545
532
|
order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
546
533
|
)
|
|
547
|
-
"""
|
|
548
|
-
)
|
|
534
|
+
""")
|
|
549
535
|
|
|
550
|
-
client.execute(
|
|
551
|
-
"""
|
|
536
|
+
client.execute("""
|
|
552
537
|
CREATE TABLE IF NOT EXISTS inventory_logs (
|
|
553
538
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
554
539
|
product_id INT,
|
|
@@ -557,8 +542,7 @@ def demo_pubsub_best_practices():
|
|
|
557
542
|
change_reason VARCHAR(100),
|
|
558
543
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
559
544
|
)
|
|
560
|
-
"""
|
|
561
|
-
)
|
|
545
|
+
""")
|
|
562
546
|
|
|
563
547
|
# Insert sample data - clear existing data
|
|
564
548
|
try:
|
|
@@ -681,8 +665,7 @@ def demo_pubsub_best_practices():
|
|
|
681
665
|
logger.info("\n📊 Business Analytics")
|
|
682
666
|
|
|
683
667
|
# Product performance
|
|
684
|
-
result = client.execute(
|
|
685
|
-
"""
|
|
668
|
+
result = client.execute("""
|
|
686
669
|
SELECT p.name, p.price, p.stock_quantity,
|
|
687
670
|
COALESCE(SUM(o.quantity), 0) as total_ordered,
|
|
688
671
|
COALESCE(SUM(o.total_amount), 0) as total_revenue
|
|
@@ -690,15 +673,13 @@ def demo_pubsub_best_practices():
|
|
|
690
673
|
LEFT JOIN orders o ON p.id = o.product_id
|
|
691
674
|
GROUP BY p.id, p.name, p.price, p.stock_quantity
|
|
692
675
|
ORDER BY total_revenue DESC
|
|
693
|
-
"""
|
|
694
|
-
)
|
|
676
|
+
""")
|
|
695
677
|
logger.info(" 📋 Product performance:")
|
|
696
678
|
for row in result.rows:
|
|
697
679
|
logger.info(f" - {row[0]}: ${row[1]}, Stock: {row[2]}, Ordered: {row[3]}, Revenue: ${row[4]:.2f}")
|
|
698
680
|
|
|
699
681
|
# Inventory status
|
|
700
|
-
result = client.execute(
|
|
701
|
-
"""
|
|
682
|
+
result = client.execute("""
|
|
702
683
|
SELECT name, stock_quantity,
|
|
703
684
|
CASE
|
|
704
685
|
WHEN stock_quantity > 50 THEN 'High'
|
|
@@ -707,8 +688,7 @@ def demo_pubsub_best_practices():
|
|
|
707
688
|
END as stock_level
|
|
708
689
|
FROM products
|
|
709
690
|
ORDER BY stock_quantity ASC
|
|
710
|
-
"""
|
|
711
|
-
)
|
|
691
|
+
""")
|
|
712
692
|
logger.info(" 📋 Inventory status:")
|
|
713
693
|
for row in result.rows:
|
|
714
694
|
logger.info(f" - {row[0]}: {row[1]} units ({row[2]} stock)")
|
{matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_13_vector_indexes.py
RENAMED
|
@@ -564,16 +564,14 @@ class VectorIndexDemo:
|
|
|
564
564
|
|
|
565
565
|
# Create test table
|
|
566
566
|
await async_client.execute("DROP TABLE IF EXISTS async_fulltext_docs")
|
|
567
|
-
await async_client.execute(
|
|
568
|
-
"""
|
|
567
|
+
await async_client.execute("""
|
|
569
568
|
CREATE TABLE async_fulltext_docs (
|
|
570
569
|
id INT PRIMARY KEY,
|
|
571
570
|
headline VARCHAR(200),
|
|
572
571
|
body TEXT,
|
|
573
572
|
category VARCHAR(50)
|
|
574
573
|
)
|
|
575
|
-
"""
|
|
576
|
-
)
|
|
574
|
+
""")
|
|
577
575
|
print("✓ Created async fulltext test table")
|
|
578
576
|
|
|
579
577
|
# Create fulltext index
|
{matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_18_snapshot_orm.py
RENAMED
|
@@ -69,8 +69,7 @@ class SnapshotORMDemo:
|
|
|
69
69
|
client.execute("DROP TABLE IF EXISTS users")
|
|
70
70
|
|
|
71
71
|
# Create table
|
|
72
|
-
client.execute(
|
|
73
|
-
"""
|
|
72
|
+
client.execute("""
|
|
74
73
|
CREATE TABLE users (
|
|
75
74
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
76
75
|
name VARCHAR(100),
|
|
@@ -78,8 +77,7 @@ class SnapshotORMDemo:
|
|
|
78
77
|
age INT,
|
|
79
78
|
department VARCHAR(50)
|
|
80
79
|
)
|
|
81
|
-
"""
|
|
82
|
-
)
|
|
80
|
+
""")
|
|
83
81
|
|
|
84
82
|
# Insert test data
|
|
85
83
|
client.execute(
|
|
@@ -157,16 +155,14 @@ class SnapshotORMDemo:
|
|
|
157
155
|
await client.execute("DROP TABLE IF EXISTS products")
|
|
158
156
|
|
|
159
157
|
# Create table
|
|
160
|
-
await client.execute(
|
|
161
|
-
"""
|
|
158
|
+
await client.execute("""
|
|
162
159
|
CREATE TABLE products (
|
|
163
160
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
164
161
|
name VARCHAR(100),
|
|
165
162
|
price DECIMAL(10,2),
|
|
166
163
|
category VARCHAR(50)
|
|
167
164
|
)
|
|
168
|
-
"""
|
|
169
|
-
)
|
|
165
|
+
""")
|
|
170
166
|
|
|
171
167
|
# Insert test data
|
|
172
168
|
await client.execute("INSERT INTO products (name, price, category) VALUES ('Laptop', 999.99, 'Electronics')")
|
|
@@ -239,18 +235,15 @@ class SnapshotORMDemo:
|
|
|
239
235
|
client.execute("DROP TABLE IF EXISTS customers")
|
|
240
236
|
|
|
241
237
|
# Create tables
|
|
242
|
-
client.execute(
|
|
243
|
-
"""
|
|
238
|
+
client.execute("""
|
|
244
239
|
CREATE TABLE customers (
|
|
245
240
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
246
241
|
name VARCHAR(100),
|
|
247
242
|
email VARCHAR(100)
|
|
248
243
|
)
|
|
249
|
-
"""
|
|
250
|
-
)
|
|
244
|
+
""")
|
|
251
245
|
|
|
252
|
-
client.execute(
|
|
253
|
-
"""
|
|
246
|
+
client.execute("""
|
|
254
247
|
CREATE TABLE orders (
|
|
255
248
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
256
249
|
customer_id INT,
|
|
@@ -258,8 +251,7 @@ class SnapshotORMDemo:
|
|
|
258
251
|
amount DECIMAL(10,2),
|
|
259
252
|
FOREIGN KEY (customer_id) REFERENCES customers(id)
|
|
260
253
|
)
|
|
261
|
-
"""
|
|
262
|
-
)
|
|
254
|
+
""")
|
|
263
255
|
|
|
264
256
|
# Insert test data
|
|
265
257
|
client.execute("INSERT INTO customers (name, email) VALUES ('John', 'john@example.com')")
|
|
@@ -330,16 +322,14 @@ class SnapshotORMDemo:
|
|
|
330
322
|
client.execute("USE builder_methods_test")
|
|
331
323
|
client.execute("DROP TABLE IF EXISTS test_data")
|
|
332
324
|
|
|
333
|
-
client.execute(
|
|
334
|
-
"""
|
|
325
|
+
client.execute("""
|
|
335
326
|
CREATE TABLE test_data (
|
|
336
327
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
|
337
328
|
name VARCHAR(100),
|
|
338
329
|
value INT,
|
|
339
330
|
category VARCHAR(50)
|
|
340
331
|
)
|
|
341
|
-
"""
|
|
342
|
-
)
|
|
332
|
+
""")
|
|
343
333
|
|
|
344
334
|
# Insert test data
|
|
345
335
|
client.execute("INSERT INTO test_data (name, value, category) VALUES ('Item1', 10, 'A')")
|
|
@@ -243,8 +243,7 @@ class UnifiedSQLBuilderDemo:
|
|
|
243
243
|
try:
|
|
244
244
|
# Create test tables
|
|
245
245
|
self.client.execute("DROP TABLE IF EXISTS test_users_cte")
|
|
246
|
-
self.client.execute(
|
|
247
|
-
"""
|
|
246
|
+
self.client.execute("""
|
|
248
247
|
CREATE TABLE test_users_cte (
|
|
249
248
|
id INT PRIMARY KEY,
|
|
250
249
|
name VARCHAR(100),
|
|
@@ -252,45 +251,37 @@ class UnifiedSQLBuilderDemo:
|
|
|
252
251
|
salary DECIMAL(10,2),
|
|
253
252
|
email VARCHAR(100)
|
|
254
253
|
)
|
|
255
|
-
"""
|
|
256
|
-
)
|
|
254
|
+
""")
|
|
257
255
|
|
|
258
256
|
self.client.execute("DROP TABLE IF EXISTS test_departments_cte")
|
|
259
|
-
self.client.execute(
|
|
260
|
-
"""
|
|
257
|
+
self.client.execute("""
|
|
261
258
|
CREATE TABLE test_departments_cte (
|
|
262
259
|
id INT PRIMARY KEY,
|
|
263
260
|
name VARCHAR(100),
|
|
264
261
|
budget DECIMAL(12,2)
|
|
265
262
|
)
|
|
266
|
-
"""
|
|
267
|
-
)
|
|
263
|
+
""")
|
|
268
264
|
|
|
269
265
|
# Insert sample data
|
|
270
|
-
self.client.execute(
|
|
271
|
-
"""
|
|
266
|
+
self.client.execute("""
|
|
272
267
|
INSERT INTO test_departments_cte (id, name, budget) VALUES
|
|
273
268
|
(1, 'Engineering', 100000),
|
|
274
269
|
(2, 'Marketing', 50000),
|
|
275
270
|
(3, 'Sales', 80000),
|
|
276
271
|
(4, 'HR', 30000)
|
|
277
|
-
"""
|
|
278
|
-
)
|
|
272
|
+
""")
|
|
279
273
|
|
|
280
|
-
self.client.execute(
|
|
281
|
-
"""
|
|
274
|
+
self.client.execute("""
|
|
282
275
|
INSERT INTO test_users_cte (id, name, department_id, salary, email) VALUES
|
|
283
276
|
(1, 'John Doe', 1, 75000, 'john@example.com'),
|
|
284
277
|
(2, 'Jane Smith', 1, 80000, 'jane@example.com'),
|
|
285
278
|
(3, 'Bob Johnson', 2, 60000, 'bob@example.com'),
|
|
286
279
|
(4, 'Alice Brown', 3, 70000, 'alice@example.com'),
|
|
287
280
|
(5, 'Charlie Wilson', 4, 55000, 'charlie@example.com')
|
|
288
|
-
"""
|
|
289
|
-
)
|
|
281
|
+
""")
|
|
290
282
|
|
|
291
283
|
# Test CTE with department statistics using new CTE support
|
|
292
|
-
results = self.client.execute(
|
|
293
|
-
"""
|
|
284
|
+
results = self.client.execute("""
|
|
294
285
|
WITH dept_stats AS (
|
|
295
286
|
SELECT
|
|
296
287
|
department_id,
|
|
@@ -308,16 +299,14 @@ class UnifiedSQLBuilderDemo:
|
|
|
308
299
|
FROM dept_stats
|
|
309
300
|
WHERE avg_salary > 65000
|
|
310
301
|
ORDER BY avg_salary DESC
|
|
311
|
-
"""
|
|
312
|
-
)
|
|
302
|
+
""")
|
|
313
303
|
|
|
314
304
|
print(f"✅ CTE department statistics: {len(results)} results")
|
|
315
305
|
for row in results:
|
|
316
306
|
print(f" Dept {row.department_id}: {row.user_count} users, avg: ${row.avg_salary:.2f}")
|
|
317
307
|
|
|
318
308
|
# Test CTE with JOINs using new CTE support
|
|
319
|
-
results2 = self.client.execute(
|
|
320
|
-
"""
|
|
309
|
+
results2 = self.client.execute("""
|
|
321
310
|
WITH high_salary_users AS (
|
|
322
311
|
SELECT id, name, department_id, salary
|
|
323
312
|
FROM test_users_cte
|
|
@@ -330,8 +319,7 @@ class UnifiedSQLBuilderDemo:
|
|
|
330
319
|
FROM high_salary_users
|
|
331
320
|
INNER JOIN test_departments_cte d ON high_salary_users.department_id = d.id
|
|
332
321
|
ORDER BY high_salary_users.salary DESC
|
|
333
|
-
"""
|
|
334
|
-
)
|
|
322
|
+
""")
|
|
335
323
|
|
|
336
324
|
print(f"✅ CTE with JOINs: {len(results2)} results")
|
|
337
325
|
for row in results2:
|
{matrixone_python_sdk-0.1.12 → matrixone_python_sdk-0.1.14}/examples/example_29_complex_queries.py
RENAMED
|
@@ -158,30 +158,25 @@ class ComplexQueryDemo:
|
|
|
158
158
|
self.client.create_table(Embedding)
|
|
159
159
|
|
|
160
160
|
# Insert categories
|
|
161
|
-
self.client.execute(
|
|
162
|
-
"""
|
|
161
|
+
self.client.execute("""
|
|
163
162
|
INSERT INTO categories_complex (category_name) VALUES
|
|
164
163
|
('Electronics'),
|
|
165
164
|
('Clothing'),
|
|
166
165
|
('Books')
|
|
167
|
-
"""
|
|
168
|
-
)
|
|
166
|
+
""")
|
|
169
167
|
|
|
170
168
|
# Insert products
|
|
171
|
-
self.client.execute(
|
|
172
|
-
"""
|
|
169
|
+
self.client.execute("""
|
|
173
170
|
INSERT INTO products_complex (product_name, description, category_id, price) VALUES
|
|
174
171
|
('Laptop', 'High performance laptop for coding', 1, 999.99),
|
|
175
172
|
('Smartphone', 'Latest smartphone with great camera', 1, 699.99),
|
|
176
173
|
('T-Shirt', 'Comfortable cotton t-shirt', 2, 19.99),
|
|
177
174
|
('Python Book', 'Learn Python programming', 3, 39.99),
|
|
178
175
|
('ML Book', 'Machine learning fundamentals', 3, 49.99)
|
|
179
|
-
"""
|
|
180
|
-
)
|
|
176
|
+
""")
|
|
181
177
|
|
|
182
178
|
# Insert reviews
|
|
183
|
-
self.client.execute(
|
|
184
|
-
"""
|
|
179
|
+
self.client.execute("""
|
|
185
180
|
INSERT INTO reviews_complex (product_id, rating, comment) VALUES
|
|
186
181
|
(1, 5, 'Excellent laptop for development'),
|
|
187
182
|
(1, 4, 'Good value for money'),
|
|
@@ -189,8 +184,7 @@ class ComplexQueryDemo:
|
|
|
189
184
|
(3, 3, 'Decent quality'),
|
|
190
185
|
(4, 5, 'Great for beginners'),
|
|
191
186
|
(5, 5, 'Very insightful')
|
|
192
|
-
"""
|
|
193
|
-
)
|
|
187
|
+
""")
|
|
194
188
|
|
|
195
189
|
# Insert embeddings with vectors
|
|
196
190
|
def generate_vector(dim=64):
|
|
@@ -200,14 +194,12 @@ class ComplexQueryDemo:
|
|
|
200
194
|
vec = [random.random() for _ in range(dim)]
|
|
201
195
|
return '[' + ','.join(map(str, vec)) + ']'
|
|
202
196
|
|
|
203
|
-
self.client.execute(
|
|
204
|
-
f"""
|
|
197
|
+
self.client.execute(f"""
|
|
205
198
|
INSERT INTO embeddings_complex (category_id, text, vector) VALUES
|
|
206
199
|
(1, 'tech gadgets', '{generate_vector(64)}'),
|
|
207
200
|
(2, 'fashion apparel', '{generate_vector(64)}'),
|
|
208
201
|
(3, 'educational content', '{generate_vector(64)}')
|
|
209
|
-
"""
|
|
210
|
-
)
|
|
202
|
+
""")
|
|
211
203
|
|
|
212
204
|
print("✓ Test data populated\n")
|
|
213
205
|
|