matrixone-python-sdk 0.1.13__tar.gz → 0.1.15__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 (97) hide show
  1. {matrixone_python_sdk-0.1.13/matrixone_python_sdk.egg-info → matrixone_python_sdk-0.1.15}/PKG-INFO +1 -1
  2. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/README.md +6 -0
  3. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_08_pubsub_operations.py +20 -40
  4. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_13_vector_indexes.py +2 -4
  5. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_18_snapshot_orm.py +10 -20
  6. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_22_unified_sql_builder.py +12 -24
  7. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_29_complex_queries.py +8 -16
  8. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_32_branch_operations.py +15 -13
  9. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_33_ivf_rank_search.py +12 -30
  10. matrixone_python_sdk-0.1.15/examples/example_34_branch_diff_count.py +317 -0
  11. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_dynamic_logging.py +8 -16
  12. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/__init__.py +1 -1
  13. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/async_client.py +54 -12
  14. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/branch.py +113 -78
  15. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/client.py +53 -14
  16. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/ivf_rank.py +32 -34
  17. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/pitr.py +8 -8
  18. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/restore.py +2 -6
  19. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/dialect.py +31 -14
  20. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/fulltext_index.py +7 -5
  21. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/vector_manager.py +46 -53
  22. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15/matrixone_python_sdk.egg-info}/PKG-INFO +1 -1
  23. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/SOURCES.txt +1 -0
  24. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/pyproject.toml +1 -1
  25. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/LICENSE +0 -0
  26. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/MANIFEST.in +0 -0
  27. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/README_USER.md +0 -0
  28. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_01_basic_connection.py +0 -0
  29. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_02_account_management.py +0 -0
  30. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_03_async_operations.py +0 -0
  31. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_04_transaction_management.py +0 -0
  32. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_05_snapshot_restore.py +0 -0
  33. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_06_sqlalchemy_integration.py +0 -0
  34. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_07_advanced_features.py +0 -0
  35. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_09_logger_integration.py +0 -0
  36. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_10_version_management.py +0 -0
  37. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_11_matrixone_version_demo.py +0 -0
  38. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_12_vector_basics.py +0 -0
  39. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_14_vector_search.py +0 -0
  40. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_15_vector_advanced.py +0 -0
  41. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_19_sqlalchemy_style_orm.py +0 -0
  42. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_20_sqlalchemy_engine_integration.py +0 -0
  43. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_21_advanced_orm_features.py +0 -0
  44. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_23_load_data_operations.py +0 -0
  45. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_24_query_update.py +0 -0
  46. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_25_metadata_operations.py +0 -0
  47. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_26_stage_operations.py +0 -0
  48. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_27_export_operations.py +0 -0
  49. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_28_sqlalchemy_select.py +0 -0
  50. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_30_with_snapshot_method.py +0 -0
  51. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_31_cdc_operations.py +0 -0
  52. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_connection_hooks.py +0 -0
  53. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/examples/example_ivf_stats_complete.py +0 -0
  54. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/account.py +0 -0
  55. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/async_orm.py +0 -0
  56. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/base_client.py +0 -0
  57. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/cdc.py +0 -0
  58. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/cli_tools.py +0 -0
  59. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/clone.py +0 -0
  60. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/config.py +0 -0
  61. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/connection_hooks.py +0 -0
  62. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/exceptions.py +0 -0
  63. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/export.py +0 -0
  64. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/fulltext_manager.py +0 -0
  65. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/index_utils.py +0 -0
  66. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/load_data.py +0 -0
  67. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/logger.py +0 -0
  68. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/metadata.py +0 -0
  69. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/moctl.py +0 -0
  70. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/orm.py +0 -0
  71. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/pubsub.py +0 -0
  72. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/search_vector_index.py +0 -0
  73. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/session.py +0 -0
  74. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/snapshot.py +0 -0
  75. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sql_builder.py +0 -0
  76. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/__init__.py +0 -0
  77. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/fulltext_search.py +0 -0
  78. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/hnsw_config.py +0 -0
  79. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/ivf_config.py +0 -0
  80. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/json_functions.py +0 -0
  81. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/json_type.py +0 -0
  82. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/snapshot.py +0 -0
  83. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/table_builder.py +0 -0
  84. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/vector_index.py +0 -0
  85. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_ext/vector_type.py +0 -0
  86. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/sqlalchemy_select.py +0 -0
  87. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/stage.py +0 -0
  88. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone/version.py +0 -0
  89. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/dependency_links.txt +0 -0
  90. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/entry_points.txt +0 -0
  91. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/not-zip-safe +0 -0
  92. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/requires.txt +0 -0
  93. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/matrixone_python_sdk.egg-info/top_level.txt +0 -0
  94. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/mo_diag.py +0 -0
  95. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/requirements.txt +0 -0
  96. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/setup.cfg +0 -0
  97. {matrixone_python_sdk-0.1.13 → matrixone_python_sdk-0.1.15}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrixone-python-sdk
3
- Version: 0.1.13
3
+ Version: 0.1.15
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
@@ -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
@@ -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)")
@@ -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
@@ -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:
@@ -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
 
@@ -33,6 +33,7 @@ This example demonstrates the complete branch functionality of MatrixOne.
33
33
  import asyncio
34
34
  import time
35
35
  from matrixone import Client, AsyncClient
36
+ from matrixone.branch import DiffOutput, MergeConflictStrategy
36
37
  from matrixone.orm import declarative_base
37
38
  from sqlalchemy import Column, Integer, String, Numeric
38
39
  from matrixone.logger import create_default_logger
@@ -40,6 +41,7 @@ from matrixone.config import get_connection_params, print_config
40
41
 
41
42
  Base = declarative_base()
42
43
 
44
+
43
45
  class Product(Base):
44
46
  __tablename__ = 'products'
45
47
  id = Column(Integer, primary_key=True)
@@ -148,11 +150,11 @@ class BranchOperationsDemo:
148
150
  # Make changes in dev (data only, not schema)
149
151
  client.execute("INSERT INTO users_dev VALUES (3, 'Charlie', 'charlie@example.com', 'active')")
150
152
 
151
- # Compare
152
- diffs = client.branch.diff('users_dev', 'users_prod')
153
+ # Compare (get count of differences)
154
+ diffs = client.branch.diff('users_dev', 'users_prod', output=DiffOutput.COUNT)
153
155
 
154
156
  # Merge
155
- client.branch.merge('users_dev', 'users_prod', on_conflict='accept')
157
+ client.branch.merge('users_dev', 'users_prod', on_conflict=MergeConflictStrategy.ACCEPT)
156
158
  result = client.execute("SELECT COUNT(*) FROM users_prod")
157
159
  count = result.rows[0][0]
158
160
 
@@ -255,7 +257,7 @@ class BranchOperationsDemo:
255
257
  avg_b = float(result.rows[0][0])
256
258
 
257
259
  # Merge winner
258
- client.branch.merge('products_b', 'products', on_conflict='accept')
260
+ client.branch.merge('products_b', 'products', on_conflict=MergeConflictStrategy.ACCEPT)
259
261
 
260
262
  client.execute("DROP TABLE products_a")
261
263
  client.execute("DROP TABLE products_b")
@@ -302,8 +304,8 @@ class BranchOperationsDemo:
302
304
  client.execute("UPDATE inventory_team_b SET quantity = 150 WHERE id = 1")
303
305
 
304
306
  # Merge both
305
- client.branch.merge('inventory_team_a', 'inventory', on_conflict='accept')
306
- client.branch.merge('inventory_team_b', 'inventory', on_conflict='accept')
307
+ client.branch.merge('inventory_team_a', 'inventory', on_conflict=MergeConflictStrategy.ACCEPT)
308
+ client.branch.merge('inventory_team_b', 'inventory', on_conflict=MergeConflictStrategy.ACCEPT)
307
309
 
308
310
  client.execute("DROP TABLE inventory_team_a")
309
311
  client.execute("DROP TABLE inventory_team_b")
@@ -392,7 +394,7 @@ class BranchOperationsDemo:
392
394
 
393
395
  # Async branch operations
394
396
  await async_client.branch.create('async_test_branch', 'async_test')
395
- diffs = await async_client.branch.diff('async_test_branch', 'async_test')
397
+ diffs = await async_client.branch.diff('async_test_branch', 'async_test', output=DiffOutput.COUNT)
396
398
  await async_client.branch.delete('async_test_branch')
397
399
 
398
400
  await async_client.execute("DROP TABLE async_test")
@@ -408,9 +410,9 @@ class BranchOperationsDemo:
408
410
 
409
411
  def generate_summary_report(self):
410
412
  """Generate comprehensive summary report."""
411
- print("\n" + "="*80)
413
+ print("\n" + "=" * 80)
412
414
  print("Branch Operations Demo - Summary Report")
413
- print("="*80)
415
+ print("=" * 80)
414
416
 
415
417
  total_tests = self.results['tests_run']
416
418
  passed_tests = self.results['tests_passed']
@@ -434,9 +436,9 @@ class BranchOperationsDemo:
434
436
 
435
437
  def run_all_tests(self):
436
438
  """Run all tests"""
437
- print("\n" + "="*80)
439
+ print("\n" + "=" * 80)
438
440
  print("MatrixOne Branch Operations - Complete Examples")
439
- print("="*80)
441
+ print("=" * 80)
440
442
  print_config()
441
443
 
442
444
  self.test_basic_api()
@@ -450,9 +452,9 @@ class BranchOperationsDemo:
450
452
 
451
453
  results = self.generate_summary_report()
452
454
 
453
- print("\n" + "="*80)
455
+ print("\n" + "=" * 80)
454
456
  print("Key Features Demonstrated:")
455
- print("="*80)
457
+ print("=" * 80)
456
458
  print("1. ✓ Simple API: create(), delete(), diff(), merge()")
457
459
  print("2. ✓ ORM Model Support: Works with SQLAlchemy models")
458
460
  print("3. ✓ Development Workflow: Isolate, test, merge changes")