matrixone-python-sdk 0.1.0__tar.gz → 0.1.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.
- {matrixone_python_sdk-0.1.0/matrixone_python_sdk.egg-info → matrixone_python_sdk-0.1.1}/PKG-INFO +17 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/README.md +16 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/README_USER.md +16 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_01_basic_connection.py +11 -11
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_02_account_management.py +8 -4
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_03_async_operations.py +5 -5
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_04_transaction_management.py +3 -3
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_05_snapshot_restore.py +4 -4
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_06_sqlalchemy_integration.py +13 -9
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_07_advanced_features.py +6 -6
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_08_pubsub_operations.py +25 -11
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_09_logger_integration.py +4 -4
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_10_version_management.py +1 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_11_matrixone_version_demo.py +1 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_13_vector_indexes.py +1 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_18_snapshot_orm.py +4 -4
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_19_sqlalchemy_style_orm.py +21 -12
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_21_advanced_orm_features.py +1 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_22_unified_sql_builder.py +3 -2
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_25_metadata_operations.py +4 -2
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_dynamic_logging.py +3 -3
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_client.py +24 -8
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/client.py +41 -8
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/restore.py +6 -2
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1/matrixone_python_sdk.egg-info}/PKG-INFO +17 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/pyproject.toml +1 -1
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/LICENSE +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/MANIFEST.in +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_12_vector_basics.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_14_vector_search.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_15_vector_advanced.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_20_sqlalchemy_engine_integration.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_24_query_update.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_connection_hooks.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_ivf_stats_complete.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/__init__.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/account.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_metadata_manager.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_orm.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_vector_index_manager.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/base_client.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/config.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/connection_hooks.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/exceptions.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/logger.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/metadata.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/moctl.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/orm.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/pitr.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/pubsub.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/search_vector_index.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/snapshot.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sql_builder.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/__init__.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/adapters.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/dialect.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/fulltext_index.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/fulltext_search.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/hnsw_config.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/ivf_config.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/table_builder.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/vector_index.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/vector_type.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/version.py +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/SOURCES.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/dependency_links.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/entry_points.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/not-zip-safe +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/requires.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/top_level.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/requirements.txt +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/setup.cfg +0 -0
- {matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/setup.py +0 -0
{matrixone_python_sdk-0.1.0/matrixone_python_sdk.egg-info → matrixone_python_sdk-0.1.1}/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.1
|
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
|
@@ -185,6 +185,22 @@ print(f"MatrixOne version: {version}")
|
|
185
185
|
client.disconnect()
|
186
186
|
```
|
187
187
|
|
188
|
+
> **📝 Connection Parameters**
|
189
|
+
>
|
190
|
+
> The `connect()` method requires **keyword arguments** (not positional):
|
191
|
+
> - `database` - **Required**, no default value
|
192
|
+
> - `host` - Default: `'localhost'`
|
193
|
+
> - `port` - Default: `6001`
|
194
|
+
> - `user` - Default: `'root'`
|
195
|
+
> - `password` - Default: `'111'`
|
196
|
+
>
|
197
|
+
> **Minimal connection** (uses all defaults):
|
198
|
+
> ```python
|
199
|
+
> client.connect(database='test')
|
200
|
+
> ```
|
201
|
+
>
|
202
|
+
> By default, all features (IVF, HNSW, fulltext) are automatically enabled via `on_connect=[ConnectionAction.ENABLE_ALL]`.
|
203
|
+
|
188
204
|
### Async Usage
|
189
205
|
|
190
206
|
```python
|
@@ -143,6 +143,22 @@ print(f"MatrixOne version: {version}")
|
|
143
143
|
client.disconnect()
|
144
144
|
```
|
145
145
|
|
146
|
+
> **📝 Connection Parameters**
|
147
|
+
>
|
148
|
+
> The `connect()` method requires **keyword arguments** (not positional):
|
149
|
+
> - `database` - **Required**, no default value
|
150
|
+
> - `host` - Default: `'localhost'`
|
151
|
+
> - `port` - Default: `6001`
|
152
|
+
> - `user` - Default: `'root'`
|
153
|
+
> - `password` - Default: `'111'`
|
154
|
+
>
|
155
|
+
> **Minimal connection** (uses all defaults):
|
156
|
+
> ```python
|
157
|
+
> client.connect(database='test')
|
158
|
+
> ```
|
159
|
+
>
|
160
|
+
> By default, all features (IVF, HNSW, fulltext) are automatically enabled via `on_connect=[ConnectionAction.ENABLE_ALL]`.
|
161
|
+
|
146
162
|
### Async Usage
|
147
163
|
|
148
164
|
```python
|
@@ -120,6 +120,22 @@ print(f"MatrixOne version: {version}")
|
|
120
120
|
client.disconnect()
|
121
121
|
```
|
122
122
|
|
123
|
+
> **📝 Connection Parameters**
|
124
|
+
>
|
125
|
+
> The `connect()` method requires **keyword arguments** (not positional):
|
126
|
+
> - `database` - **Required**, no default value
|
127
|
+
> - `host` - Default: `'localhost'`
|
128
|
+
> - `port` - Default: `6001`
|
129
|
+
> - `user` - Default: `'root'`
|
130
|
+
> - `password` - Default: `'111'`
|
131
|
+
>
|
132
|
+
> **Minimal connection** (uses all defaults):
|
133
|
+
> ```python
|
134
|
+
> client.connect(database='test')
|
135
|
+
> ```
|
136
|
+
>
|
137
|
+
> By default, all features (IVF, HNSW, fulltext) are automatically enabled via `on_connect=[ConnectionAction.ENABLE_ALL]`.
|
138
|
+
|
123
139
|
### Async Usage
|
124
140
|
|
125
141
|
```python
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_01_basic_connection.py
RENAMED
@@ -66,7 +66,7 @@ class BasicConnectionDemo:
|
|
66
66
|
# Test 1: Simple connection
|
67
67
|
self.logger.info("Test 1: Simple Connection")
|
68
68
|
client = Client(logger=self.logger, sql_log_mode="full")
|
69
|
-
client.connect(host, port, user, password, database)
|
69
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
70
70
|
self.logger.info("✅ Basic connection successful")
|
71
71
|
|
72
72
|
# Test basic query
|
@@ -99,7 +99,7 @@ class BasicConnectionDemo:
|
|
99
99
|
# Format 1: Legacy format (simple username)
|
100
100
|
self.logger.info("Format 1: Legacy format (simple username)")
|
101
101
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
102
|
-
client.connect(host, port, user, password, database)
|
102
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
103
103
|
login_info = client.get_login_info()
|
104
104
|
self.logger.info(f" ✅ Login info: {login_info}")
|
105
105
|
client.disconnect()
|
@@ -107,7 +107,7 @@ class BasicConnectionDemo:
|
|
107
107
|
# Format 2: Direct format (account#user)
|
108
108
|
self.logger.info("Format 2: Direct format (account#user)")
|
109
109
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
110
|
-
client.connect(host, port, 'sys#root', password, database)
|
110
|
+
client.connect(host=host, port=port, user='sys#root', password=password, database=database)
|
111
111
|
login_info = client.get_login_info()
|
112
112
|
self.logger.info(f" ✅ Login info: {login_info}")
|
113
113
|
client.disconnect()
|
@@ -116,7 +116,7 @@ class BasicConnectionDemo:
|
|
116
116
|
self.logger.info("Format 3: User with role (separate parameters)")
|
117
117
|
try:
|
118
118
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
119
|
-
client.connect(host, port, user, password, database, role='admin')
|
119
|
+
client.connect(host=host, port=port, user=user, password=password, database=database, role='admin')
|
120
120
|
# Try to execute a query to trigger role validation
|
121
121
|
client.execute("SELECT 1")
|
122
122
|
login_info = client.get_login_info()
|
@@ -128,7 +128,7 @@ class BasicConnectionDemo:
|
|
128
128
|
# Format 4: Account with separate parameters
|
129
129
|
self.logger.info("Format 4: Account with separate parameters")
|
130
130
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
131
|
-
client.connect(host, port, user, password, database, account='sys')
|
131
|
+
client.connect(host=host, port=port, user=user, password=password, database=database, account='sys')
|
132
132
|
login_info = client.get_login_info()
|
133
133
|
self.logger.info(f" ✅ Login info: {login_info}")
|
134
134
|
client.disconnect()
|
@@ -154,7 +154,7 @@ class BasicConnectionDemo:
|
|
154
154
|
self.logger.info("Test invalid credentials")
|
155
155
|
try:
|
156
156
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
157
|
-
client.connect(host, port, 'invalid_user', 'invalid_pass', database)
|
157
|
+
client.connect(host=host, port=port, user='invalid_user', password='invalid_pass', database=database)
|
158
158
|
# Try to execute a query to trigger authentication
|
159
159
|
client.execute("SELECT 1")
|
160
160
|
self.logger.error(" ❌ Should have failed but didn't!")
|
@@ -165,7 +165,7 @@ class BasicConnectionDemo:
|
|
165
165
|
self.logger.info("Test invalid host")
|
166
166
|
try:
|
167
167
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
168
|
-
client.connect('192.168.1.999', port, user, password, database)
|
168
|
+
client.connect(host='192.168.1.999', port=port, user=user, password=password, database=database)
|
169
169
|
# Try to execute a query to trigger connection validation
|
170
170
|
client.execute("SELECT 1")
|
171
171
|
self.logger.error(" ❌ Should have failed but didn't!")
|
@@ -176,7 +176,7 @@ class BasicConnectionDemo:
|
|
176
176
|
self.logger.info("Test invalid port")
|
177
177
|
try:
|
178
178
|
client = Client(logger=self.logger, sql_log_mode="auto")
|
179
|
-
client.connect(host, 9999, user, password, database)
|
179
|
+
client.connect(host=host, port=9999, user=user, password=password, database=database)
|
180
180
|
# Try to execute a query to trigger connection validation
|
181
181
|
client.execute("SELECT 1")
|
182
182
|
self.logger.error(" ❌ Should have failed but didn't!")
|
@@ -234,7 +234,7 @@ def demo_connection_info():
|
|
234
234
|
|
235
235
|
try:
|
236
236
|
client = Client(logger=logger, sql_log_mode="auto")
|
237
|
-
client.connect(host, port, user, password, database)
|
237
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
238
238
|
|
239
239
|
# Get login info
|
240
240
|
login_info = client.get_login_info()
|
@@ -266,7 +266,7 @@ async def demo_async_connection():
|
|
266
266
|
client = None
|
267
267
|
try:
|
268
268
|
client = AsyncClient(logger=logger)
|
269
|
-
await client.connect(host, port, user, password, database)
|
269
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
270
270
|
logger.info("✅ Async connection successful")
|
271
271
|
|
272
272
|
# Test async query
|
@@ -300,7 +300,7 @@ def demo_connection_pooling():
|
|
300
300
|
# Create multiple connections
|
301
301
|
for i in range(3):
|
302
302
|
client = Client(logger=logger, sql_log_mode="auto")
|
303
|
-
client.connect(host, port, user, password, database)
|
303
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
304
304
|
clients.append(client)
|
305
305
|
logger.info(f" ✅ Created connection {i+1}")
|
306
306
|
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_02_account_management.py
RENAMED
@@ -67,7 +67,7 @@ class AccountManagementDemo:
|
|
67
67
|
|
68
68
|
# Connect as root for account management
|
69
69
|
root_client = Client(logger=self.logger, sql_log_mode="full")
|
70
|
-
root_client.connect(host, port, user, password, database)
|
70
|
+
root_client.connect(host=host, port=port, user=user, password=password, database=database)
|
71
71
|
account_manager = AccountManager(root_client)
|
72
72
|
|
73
73
|
# Clean up any existing demo accounts
|
@@ -112,7 +112,9 @@ class AccountManagementDemo:
|
|
112
112
|
try:
|
113
113
|
# Connect as demo account admin
|
114
114
|
demo_admin_client = Client(sql_log_mode="full")
|
115
|
-
demo_admin_client.connect(
|
115
|
+
demo_admin_client.connect(
|
116
|
+
host=host, port=port, user='demo_account#demo_admin', password='adminpass123', database='mo_catalog'
|
117
|
+
)
|
116
118
|
demo_account_manager = AccountManager(demo_admin_client)
|
117
119
|
|
118
120
|
# Create users
|
@@ -145,7 +147,9 @@ class AccountManagementDemo:
|
|
145
147
|
try:
|
146
148
|
# Connect as demo account admin
|
147
149
|
demo_admin_client = Client(sql_log_mode="full")
|
148
|
-
demo_admin_client.connect(
|
150
|
+
demo_admin_client.connect(
|
151
|
+
host=host, port=port, user='demo_account#demo_admin', password='adminpass123', database='mo_catalog'
|
152
|
+
)
|
149
153
|
demo_account_manager = AccountManager(demo_admin_client)
|
150
154
|
|
151
155
|
# Create roles
|
@@ -219,7 +223,7 @@ class AccountManagementDemo:
|
|
219
223
|
|
220
224
|
# Connect as root
|
221
225
|
root_client = AsyncClient(sql_log_mode="full")
|
222
|
-
await root_client.connect(host, port, user, password, database)
|
226
|
+
await root_client.connect(host=host, port=port, user=user, password=password, database=database)
|
223
227
|
self.logger.info("✅ Async connection successful")
|
224
228
|
|
225
229
|
# Test basic async operations
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_03_async_operations.py
RENAMED
@@ -67,7 +67,7 @@ class AsyncOperationsDemo:
|
|
67
67
|
self.logger.info("Test 1: Basic Async Connection")
|
68
68
|
try:
|
69
69
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
70
|
-
await client.connect(host, port, user, password, database)
|
70
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
71
71
|
self.logger.info("✅ Async connection successful")
|
72
72
|
|
73
73
|
# Test basic async query
|
@@ -107,7 +107,7 @@ class AsyncOperationsDemo:
|
|
107
107
|
self.logger.info("Test: Async Query Execution")
|
108
108
|
try:
|
109
109
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
110
|
-
await client.connect(host, port, user, password, database)
|
110
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
111
111
|
|
112
112
|
# Test various query types
|
113
113
|
queries = [
|
@@ -149,7 +149,7 @@ class AsyncOperationsDemo:
|
|
149
149
|
self.logger.info("Test: Async Transaction Management")
|
150
150
|
try:
|
151
151
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
152
|
-
await client.connect(host, port, user, password, database)
|
152
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
153
153
|
|
154
154
|
# Test transaction operations
|
155
155
|
await client.execute("START TRANSACTION")
|
@@ -193,7 +193,7 @@ class AsyncOperationsDemo:
|
|
193
193
|
clients = []
|
194
194
|
for i in range(3):
|
195
195
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
196
|
-
await client.connect(host, port, user, password, database)
|
196
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
197
197
|
clients.append(client)
|
198
198
|
self.logger.info(f" ✅ Created async connection {i+1}")
|
199
199
|
|
@@ -239,7 +239,7 @@ class AsyncOperationsDemo:
|
|
239
239
|
self.logger.info("Test: Async Error Handling")
|
240
240
|
try:
|
241
241
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
242
|
-
await client.connect(host, port, user, password, database)
|
242
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
243
243
|
|
244
244
|
# Test invalid query (should raise error)
|
245
245
|
try:
|
@@ -59,7 +59,7 @@ class TransactionManagementDemo:
|
|
59
59
|
host, port, user, password, database = get_connection_params()
|
60
60
|
|
61
61
|
client = Client(logger=self.logger, sql_log_mode="full")
|
62
|
-
client.connect(host, port, user, password, database)
|
62
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
63
63
|
|
64
64
|
# Test 1: Simple transaction with commit
|
65
65
|
self.logger.info("Test 1: Simple Transaction with Commit")
|
@@ -163,7 +163,7 @@ class TransactionManagementDemo:
|
|
163
163
|
host, port, user, password, database = get_connection_params()
|
164
164
|
|
165
165
|
client = Client(logger=self.logger, sql_log_mode="full")
|
166
|
-
client.connect(host, port, user, password, database)
|
166
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
167
167
|
|
168
168
|
# Test error handling in transaction
|
169
169
|
self.logger.info("Test: Transaction Error Handling")
|
@@ -236,7 +236,7 @@ class TransactionManagementDemo:
|
|
236
236
|
host, port, user, password, database = get_connection_params()
|
237
237
|
|
238
238
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
239
|
-
await client.connect(host, port, user, password, database)
|
239
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
240
240
|
|
241
241
|
# Test async transaction
|
242
242
|
self.logger.info("Test: Async Transaction Management")
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_05_snapshot_restore.py
RENAMED
@@ -59,7 +59,7 @@ class SnapshotRestoreDemo:
|
|
59
59
|
host, port, user, password, database = get_connection_params()
|
60
60
|
|
61
61
|
client = Client(logger=self.logger, sql_log_mode="full")
|
62
|
-
client.connect(host, port, user, password, database)
|
62
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
63
63
|
|
64
64
|
# Test 1: Create test data
|
65
65
|
self.logger.info("Test 1: Create Test Data")
|
@@ -186,7 +186,7 @@ class SnapshotRestoreDemo:
|
|
186
186
|
host, port, user, password, database = get_connection_params()
|
187
187
|
|
188
188
|
client = Client(logger=self.logger, sql_log_mode="full")
|
189
|
-
client.connect(host, port, user, password, database)
|
189
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
190
190
|
|
191
191
|
# Test snapshot enumeration
|
192
192
|
self.logger.info("Test: Snapshot Enumeration")
|
@@ -223,7 +223,7 @@ class SnapshotRestoreDemo:
|
|
223
223
|
host, port, user, password, database = get_connection_params()
|
224
224
|
|
225
225
|
client = Client(logger=self.logger, sql_log_mode="full")
|
226
|
-
client.connect(host, port, user, password, database)
|
226
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
227
227
|
|
228
228
|
# Test error handling
|
229
229
|
self.logger.info("Test: Snapshot Error Handling")
|
@@ -266,7 +266,7 @@ class SnapshotRestoreDemo:
|
|
266
266
|
host, port, user, password, database = get_connection_params()
|
267
267
|
|
268
268
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
269
|
-
await client.connect(host, port, user, password, database)
|
269
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
270
270
|
|
271
271
|
# Test async snapshot operations
|
272
272
|
self.logger.info("Test: Async Snapshot Operations")
|
@@ -30,8 +30,8 @@ This example shows the complete SQLAlchemy integration capabilities.
|
|
30
30
|
|
31
31
|
import logging
|
32
32
|
import asyncio
|
33
|
-
from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, ForeignKey, text
|
34
|
-
from sqlalchemy.orm import declarative_base, sessionmaker, relationship
|
33
|
+
from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, ForeignKey, text, and_
|
34
|
+
from sqlalchemy.orm import declarative_base, sessionmaker, relationship, foreign
|
35
35
|
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
36
36
|
from sqlalchemy.pool import QueuePool
|
37
37
|
from matrixone import Client, AsyncClient
|
@@ -67,8 +67,8 @@ class User(Base):
|
|
67
67
|
email = Column(String(100), unique=True, nullable=False)
|
68
68
|
created_at = Column(DateTime)
|
69
69
|
|
70
|
-
# Relationship
|
71
|
-
posts = relationship("Post", back_populates="author")
|
70
|
+
# Relationship (ORM-level only)
|
71
|
+
posts = relationship("Post", back_populates="author", primaryjoin="User.id==foreign(Post.author_id)")
|
72
72
|
|
73
73
|
|
74
74
|
class Post(Base):
|
@@ -77,11 +77,13 @@ class Post(Base):
|
|
77
77
|
id = Column(Integer, primary_key=True)
|
78
78
|
title = Column(String(200), nullable=False)
|
79
79
|
content = Column(Text)
|
80
|
-
|
80
|
+
# Note: MatrixOne may have limitations with foreign key constraints
|
81
|
+
# Using Integer column without FK constraint, but keeping ORM relationship
|
82
|
+
author_id = Column(Integer)
|
81
83
|
created_at = Column(DateTime)
|
82
84
|
|
83
|
-
# Relationship
|
84
|
-
author = relationship("User", back_populates="posts")
|
85
|
+
# Relationship (ORM-level only, no database FK constraint)
|
86
|
+
author = relationship("User", back_populates="posts", primaryjoin="foreign(Post.author_id)==User.id")
|
85
87
|
|
86
88
|
|
87
89
|
class SQLAlchemyIntegrationDemo:
|
@@ -156,7 +158,8 @@ class SQLAlchemyIntegrationDemo:
|
|
156
158
|
# Test ORM operations
|
157
159
|
self.logger.info("Test: ORM Operations")
|
158
160
|
try:
|
159
|
-
#
|
161
|
+
# Drop and recreate tables to ensure clean state
|
162
|
+
Base.metadata.drop_all(engine)
|
160
163
|
Base.metadata.create_all(engine)
|
161
164
|
self.logger.info(" Created tables")
|
162
165
|
|
@@ -218,7 +221,8 @@ class SQLAlchemyIntegrationDemo:
|
|
218
221
|
# Test transactions
|
219
222
|
self.logger.info("Test: SQLAlchemy Transactions")
|
220
223
|
try:
|
221
|
-
#
|
224
|
+
# Drop and recreate tables to ensure clean state
|
225
|
+
Base.metadata.drop_all(engine)
|
222
226
|
Base.metadata.create_all(engine)
|
223
227
|
|
224
228
|
# Test transaction with commit
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_07_advanced_features.py
RENAMED
@@ -64,7 +64,7 @@ class AdvancedFeaturesDemo:
|
|
64
64
|
host, port, user, password, database = get_connection_params()
|
65
65
|
|
66
66
|
client = Client(logger=self.logger, sql_log_mode="full")
|
67
|
-
client.connect(host, port, user, password, database)
|
67
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
68
68
|
|
69
69
|
# Test PubSub operations
|
70
70
|
self.logger.info("Test: PubSub Operations")
|
@@ -111,7 +111,7 @@ class AdvancedFeaturesDemo:
|
|
111
111
|
host, port, user, password, database = get_connection_params()
|
112
112
|
|
113
113
|
client = Client(logger=self.logger, sql_log_mode="full")
|
114
|
-
client.connect(host, port, user, password, database)
|
114
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
115
115
|
|
116
116
|
# Test clone operations
|
117
117
|
self.logger.info("Test: Clone Operations")
|
@@ -157,7 +157,7 @@ class AdvancedFeaturesDemo:
|
|
157
157
|
host, port, user, password, database = get_connection_params()
|
158
158
|
|
159
159
|
client = Client(logger=self.logger, sql_log_mode="full")
|
160
|
-
client.connect(host, port, user, password, database)
|
160
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
161
161
|
|
162
162
|
# Test MoCTL integration
|
163
163
|
self.logger.info("Test: MoCTL Integration")
|
@@ -202,7 +202,7 @@ class AdvancedFeaturesDemo:
|
|
202
202
|
host, port, user, password, database = get_connection_params()
|
203
203
|
|
204
204
|
client = Client(logger=self.logger, sql_log_mode="full")
|
205
|
-
client.connect(host, port, user, password, database)
|
205
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
206
206
|
|
207
207
|
# Test version information
|
208
208
|
self.logger.info("Test: Version Information")
|
@@ -251,7 +251,7 @@ class AdvancedFeaturesDemo:
|
|
251
251
|
host, port, user, password, database = get_connection_params()
|
252
252
|
|
253
253
|
client = Client(logger=self.logger, sql_log_mode="full")
|
254
|
-
client.connect(host, port, user, password, database)
|
254
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
255
255
|
|
256
256
|
# Test performance monitoring
|
257
257
|
self.logger.info("Test: Performance Monitoring")
|
@@ -297,7 +297,7 @@ class AdvancedFeaturesDemo:
|
|
297
297
|
host, port, user, password, database = get_connection_params()
|
298
298
|
|
299
299
|
client = AsyncClient(logger=self.logger, sql_log_mode="full")
|
300
|
-
await client.connect(host, port, user, password, database)
|
300
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
301
301
|
|
302
302
|
# Test async advanced features
|
303
303
|
self.logger.info("Test: Async Advanced Features")
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_08_pubsub_operations.py
RENAMED
@@ -62,7 +62,7 @@ class PubSubOperationsDemo:
|
|
62
62
|
host, port, user, password, database = get_connection_params()
|
63
63
|
|
64
64
|
client = Client(sql_log_mode="full")
|
65
|
-
client.connect(host, port, user, password, database)
|
65
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
66
66
|
|
67
67
|
# Test basic PubSub operations
|
68
68
|
self.logger.info("Test: Basic PubSub Operations")
|
@@ -145,7 +145,7 @@ def demo_cross_account_pubsub():
|
|
145
145
|
|
146
146
|
try:
|
147
147
|
# Connect as admin
|
148
|
-
admin_client.connect(host, port, user, password, "mo_catalog")
|
148
|
+
admin_client.connect(host=host, port=port, user=user, password=password, database="mo_catalog")
|
149
149
|
logger.info("✅ Connected as admin")
|
150
150
|
|
151
151
|
# Clean up any existing accounts first
|
@@ -193,23 +193,31 @@ def demo_cross_account_pubsub():
|
|
193
193
|
publisher_client = Client(sql_log_mode="full")
|
194
194
|
|
195
195
|
# Connect as publisher account admin
|
196
|
-
publisher_client.connect(
|
196
|
+
publisher_client.connect(
|
197
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="mo_catalog"
|
198
|
+
)
|
197
199
|
logger.info(" ✅ Connected as publisher account admin")
|
198
200
|
|
199
201
|
# Create publisher database
|
200
202
|
pub_admin_client = Client(sql_log_mode="full")
|
201
|
-
pub_admin_client.connect(
|
203
|
+
pub_admin_client.connect(
|
204
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="mo_catalog"
|
205
|
+
)
|
202
206
|
pub_admin_client.execute("CREATE DATABASE IF NOT EXISTS publisher_data")
|
203
207
|
pub_admin_client.disconnect()
|
204
208
|
|
205
209
|
# Connect to publisher database
|
206
210
|
publisher_client.disconnect()
|
207
|
-
publisher_client.connect(
|
211
|
+
publisher_client.connect(
|
212
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="publisher_data"
|
213
|
+
)
|
208
214
|
logger.info(" ✅ Connected to publisher database")
|
209
215
|
|
210
216
|
# Create tables for publishing
|
211
217
|
pub_admin_client = Client(sql_log_mode="full")
|
212
|
-
pub_admin_client.connect(
|
218
|
+
pub_admin_client.connect(
|
219
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="publisher_data"
|
220
|
+
)
|
213
221
|
|
214
222
|
pub_admin_client.execute(
|
215
223
|
"""
|
@@ -281,7 +289,9 @@ def demo_cross_account_pubsub():
|
|
281
289
|
subscriber_client = Client(sql_log_mode="full")
|
282
290
|
|
283
291
|
# Connect as subscriber account admin
|
284
|
-
subscriber_client.connect(
|
292
|
+
subscriber_client.connect(
|
293
|
+
host=host, port=port, user="pub_subscriber#sub_admin", password="sub_pass", database="mo_catalog"
|
294
|
+
)
|
285
295
|
logger.info(" ✅ Connected as subscriber account admin")
|
286
296
|
|
287
297
|
# Create subscriptions
|
@@ -300,7 +310,9 @@ def demo_cross_account_pubsub():
|
|
300
310
|
|
301
311
|
# Add new data as publisher
|
302
312
|
pub_admin_client = Client(sql_log_mode="full")
|
303
|
-
pub_admin_client.connect(
|
313
|
+
pub_admin_client.connect(
|
314
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="publisher_data"
|
315
|
+
)
|
304
316
|
|
305
317
|
pub_admin_client.execute(f"INSERT INTO sales_data (product_name, quantity, price) VALUES ('Apple Watch', 3, 399.99)")
|
306
318
|
logger.info(" 📤 Added new sales data: Apple Watch")
|
@@ -334,7 +346,9 @@ def demo_cross_account_pubsub():
|
|
334
346
|
try:
|
335
347
|
# Create new connection for cleanup
|
336
348
|
cleanup_client = Client(sql_log_mode="full")
|
337
|
-
cleanup_client.connect(
|
349
|
+
cleanup_client.connect(
|
350
|
+
host=host, port=port, user="pub_publisher#pub_admin", password="pub_pass", database="mo_catalog"
|
351
|
+
)
|
338
352
|
cleanup_client.execute("DROP DATABASE publisher_data")
|
339
353
|
cleanup_client.disconnect()
|
340
354
|
logger.info(" ✅ Dropped publisher database")
|
@@ -376,7 +390,7 @@ async def demo_async_pubsub_operations():
|
|
376
390
|
|
377
391
|
try:
|
378
392
|
# Connect to MatrixOne
|
379
|
-
await client.connect(host, port, user, password, database)
|
393
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
380
394
|
logger.info("✅ Connected to MatrixOne (async)")
|
381
395
|
|
382
396
|
# Create test database and tables
|
@@ -497,7 +511,7 @@ def demo_pubsub_best_practices():
|
|
497
511
|
|
498
512
|
try:
|
499
513
|
# Connect to MatrixOne
|
500
|
-
client.connect(host, port, user, password, database)
|
514
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
501
515
|
logger.info("✅ Connected to MatrixOne")
|
502
516
|
|
503
517
|
# Create a realistic e-commerce scenario
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_09_logger_integration.py
RENAMED
@@ -71,7 +71,7 @@ class LoggerIntegrationDemo:
|
|
71
71
|
self.logger.info("Test: Default Logger Configuration")
|
72
72
|
try:
|
73
73
|
# Connect to MatrixOne
|
74
|
-
client.connect(host, port, user, password, database)
|
74
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
75
75
|
|
76
76
|
# Execute some queries to see logging in action
|
77
77
|
client.execute("SELECT 1 as test_value")
|
@@ -127,7 +127,7 @@ class LoggerIntegrationDemo:
|
|
127
127
|
try:
|
128
128
|
# Create client with custom logger
|
129
129
|
client = Client(logger=custom_logger)
|
130
|
-
client.connect(host, port, user, password, database)
|
130
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
131
131
|
|
132
132
|
# Execute queries with custom logging
|
133
133
|
client.execute("SELECT 1 as custom_test")
|
@@ -276,7 +276,7 @@ class LoggerIntegrationDemo:
|
|
276
276
|
try:
|
277
277
|
# Create client with auto SQL logging
|
278
278
|
client = Client(sql_log_mode="auto")
|
279
|
-
client.connect(host, port, user, password, database)
|
279
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
280
280
|
|
281
281
|
# Execute queries to test performance logging
|
282
282
|
client.execute("SELECT 1 as performance_test")
|
@@ -312,7 +312,7 @@ class LoggerIntegrationDemo:
|
|
312
312
|
try:
|
313
313
|
# Create async client with auto SQL logging
|
314
314
|
client = AsyncClient(sql_log_mode="auto")
|
315
|
-
await client.connect(host, port, user, password, database)
|
315
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
316
316
|
|
317
317
|
# Execute async queries
|
318
318
|
await client.execute("SELECT 1 as async_test")
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_10_version_management.py
RENAMED
@@ -118,7 +118,7 @@ class VersionManagementDemo:
|
|
118
118
|
print("Test: Backend Version Detection")
|
119
119
|
try:
|
120
120
|
client = Client()
|
121
|
-
client.connect(host, port, user, password, database)
|
121
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
122
122
|
|
123
123
|
# Get version information
|
124
124
|
version_info = client.version()
|
@@ -231,7 +231,7 @@ class MatrixOneVersionDemo:
|
|
231
231
|
from matrixone import Client
|
232
232
|
|
233
233
|
client = Client()
|
234
|
-
client.connect(host, port, user, password, database)
|
234
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
235
235
|
|
236
236
|
# Get version information
|
237
237
|
version_info = client.version()
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_13_vector_indexes.py
RENAMED
@@ -554,7 +554,7 @@ class VectorIndexDemo:
|
|
554
554
|
# Create async client
|
555
555
|
host, port, user, password, database = get_connection_params()
|
556
556
|
async_client = AsyncClient()
|
557
|
-
await async_client.connect(host, port, user, password, database)
|
557
|
+
await async_client.connect(host=host, port=port, user=user, password=password, database=database)
|
558
558
|
|
559
559
|
try:
|
560
560
|
# Enable fulltext indexing
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_18_snapshot_orm.py
RENAMED
@@ -56,7 +56,7 @@ class SnapshotORMDemo:
|
|
56
56
|
host, port, user, password, database = get_connection_params()
|
57
57
|
|
58
58
|
client = Client(logger=self.logger)
|
59
|
-
client.connect(host, port, user, password, database)
|
59
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
60
60
|
|
61
61
|
# Test sync snapshot ORM
|
62
62
|
self.logger.info("Test: Sync Snapshot ORM")
|
@@ -144,7 +144,7 @@ class SnapshotORMDemo:
|
|
144
144
|
host, port, user, password, database = get_connection_params()
|
145
145
|
|
146
146
|
client = AsyncClient(logger=self.logger)
|
147
|
-
await client.connect(host, port, user, password, database)
|
147
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
148
148
|
|
149
149
|
# Test async snapshot ORM
|
150
150
|
self.logger.info("Test: Async Snapshot ORM")
|
@@ -225,7 +225,7 @@ class SnapshotORMDemo:
|
|
225
225
|
host, port, user, password, database = get_connection_params()
|
226
226
|
|
227
227
|
client = Client(logger=self.logger)
|
228
|
-
client.connect(host, port, user, password, database)
|
228
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
229
229
|
|
230
230
|
# Test complex snapshot queries
|
231
231
|
self.logger.info("Test: Complex Snapshot Queries")
|
@@ -320,7 +320,7 @@ class SnapshotORMDemo:
|
|
320
320
|
host, port, user, password, database = get_connection_params()
|
321
321
|
|
322
322
|
client = Client(logger=self.logger)
|
323
|
-
client.connect(host, port, user, password, database)
|
323
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
324
324
|
|
325
325
|
# Test snapshot query builder methods
|
326
326
|
self.logger.info("Test: Snapshot Query Builder Methods")
|
@@ -86,7 +86,7 @@ class SQLAlchemyStyleORMDemo:
|
|
86
86
|
host, port, user, password, database = get_connection_params()
|
87
87
|
|
88
88
|
client = Client(logger=self.logger)
|
89
|
-
client.connect(host, port, user, password, database)
|
89
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
90
90
|
|
91
91
|
# Test sync SQLAlchemy-style ORM
|
92
92
|
self.logger.info("Test: Sync SQLAlchemy-style ORM")
|
@@ -94,10 +94,13 @@ class SQLAlchemyStyleORMDemo:
|
|
94
94
|
# Create test database and table
|
95
95
|
client.execute("CREATE DATABASE IF NOT EXISTS sqlalchemy_orm_test")
|
96
96
|
client.execute("USE sqlalchemy_orm_test")
|
97
|
+
|
98
|
+
# Drop both tables to ensure clean state
|
97
99
|
client.drop_table(Product)
|
100
|
+
client.drop_table(Order)
|
98
101
|
|
99
|
-
# Create table
|
100
|
-
|
102
|
+
# Create only the Product table (we don't need Order in this test)
|
103
|
+
Product.__table__.create(client._engine)
|
101
104
|
|
102
105
|
# Insert test data
|
103
106
|
client.execute(
|
@@ -145,7 +148,7 @@ class SQLAlchemyStyleORMDemo:
|
|
145
148
|
host, port, user, password, database = get_connection_params()
|
146
149
|
|
147
150
|
client = AsyncClient(logger=self.logger)
|
148
|
-
await client.connect(host, port, user, password, database)
|
151
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
149
152
|
|
150
153
|
# Test async SQLAlchemy-style ORM
|
151
154
|
self.logger.info("Test: Async SQLAlchemy-style ORM")
|
@@ -153,11 +156,14 @@ class SQLAlchemyStyleORMDemo:
|
|
153
156
|
# Create test database and table
|
154
157
|
await client.execute("CREATE DATABASE IF NOT EXISTS async_sqlalchemy_orm_test")
|
155
158
|
await client.execute("USE async_sqlalchemy_orm_test")
|
159
|
+
|
160
|
+
# Drop both tables to ensure clean state
|
156
161
|
await client.drop_table(Order)
|
162
|
+
await client.drop_table(Product)
|
157
163
|
|
158
|
-
# Create table
|
164
|
+
# Create only the Order table (we don't need Product in async test)
|
159
165
|
async with client._engine.begin() as conn:
|
160
|
-
await conn.run_sync(
|
166
|
+
await conn.run_sync(Order.__table__.create)
|
161
167
|
|
162
168
|
# Insert test data
|
163
169
|
await client.execute(
|
@@ -205,7 +211,7 @@ class SQLAlchemyStyleORMDemo:
|
|
205
211
|
host, port, user, password, database = get_connection_params()
|
206
212
|
|
207
213
|
client = Client(logger=self.logger)
|
208
|
-
client.connect(host, port, user, password, database)
|
214
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
209
215
|
|
210
216
|
# Test ORM query methods
|
211
217
|
self.logger.info("Test: ORM Query Methods")
|
@@ -213,10 +219,13 @@ class SQLAlchemyStyleORMDemo:
|
|
213
219
|
# Create test database and table
|
214
220
|
client.execute("CREATE DATABASE IF NOT EXISTS orm_query_methods_test")
|
215
221
|
client.execute("USE orm_query_methods_test")
|
222
|
+
|
223
|
+
# Drop both tables to ensure clean state
|
216
224
|
client.drop_table(Product)
|
225
|
+
client.drop_table(Order)
|
217
226
|
|
218
|
-
# Create table
|
219
|
-
|
227
|
+
# Create only the Product table (we don't need Order in this test)
|
228
|
+
Product.__table__.create(client._engine)
|
220
229
|
|
221
230
|
# Insert test data
|
222
231
|
client.execute(
|
@@ -271,7 +280,7 @@ class SQLAlchemyStyleORMDemo:
|
|
271
280
|
host, port, user, password, database = get_connection_params()
|
272
281
|
|
273
282
|
client = Client(logger=self.logger)
|
274
|
-
client.connect(host, port, user, password, database)
|
283
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
275
284
|
|
276
285
|
# Test ORM with snapshots
|
277
286
|
self.logger.info("Test: ORM with Snapshots")
|
@@ -282,8 +291,8 @@ class SQLAlchemyStyleORMDemo:
|
|
282
291
|
client.drop_table(Product)
|
283
292
|
client.drop_table(Order)
|
284
293
|
|
285
|
-
# Create table
|
286
|
-
|
294
|
+
# Create only the Product table (we only use Product in this test)
|
295
|
+
Product.__table__.create(client._engine)
|
287
296
|
|
288
297
|
# Insert test data
|
289
298
|
client.execute(
|
@@ -112,7 +112,7 @@ class AdvancedORMFeaturesDemo:
|
|
112
112
|
host, port, user, password, database = get_connection_params()
|
113
113
|
|
114
114
|
client = Client()
|
115
|
-
client.connect(host, port, user, password, database)
|
115
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
116
116
|
|
117
117
|
# Create demo database
|
118
118
|
demo_db = "demo_advanced_orm"
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_22_unified_sql_builder.py
RENAMED
@@ -71,8 +71,9 @@ class UnifiedSQLBuilderDemo:
|
|
71
71
|
try:
|
72
72
|
print("🔗 Setting up database connection...")
|
73
73
|
connection_params = get_connection_params()
|
74
|
-
self.client = Client(
|
75
|
-
|
74
|
+
self.client = Client()
|
75
|
+
host, port, user, password, database = connection_params
|
76
|
+
self.client.connect(host=host, port=port, user=user, password=password, database=database)
|
76
77
|
print("✅ Connected to MatrixOne successfully")
|
77
78
|
return True
|
78
79
|
except Exception as e:
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_25_metadata_operations.py
RENAMED
@@ -75,7 +75,8 @@ class MetadataOperationsDemo:
|
|
75
75
|
|
76
76
|
# Create client and connect
|
77
77
|
self.client = Client(logger=self.logger)
|
78
|
-
self.
|
78
|
+
host, port, user, password, database = self.connection_params
|
79
|
+
self.client.connect(host=host, port=port, user=user, password=password, database=database)
|
79
80
|
|
80
81
|
# Get SQLAlchemy engine and create session
|
81
82
|
self.engine = self.client.get_sqlalchemy_engine()
|
@@ -357,7 +358,8 @@ class MetadataOperationsDemo:
|
|
357
358
|
self.logger.info("\n=== Asynchronous Metadata Operations ===")
|
358
359
|
|
359
360
|
client = AsyncClient()
|
360
|
-
|
361
|
+
host, port, user, password, database = self.connection_params
|
362
|
+
await client.connect(host=host, port=port, user=user, password=password, database=database)
|
361
363
|
|
362
364
|
try:
|
363
365
|
# Async metadata scan with raw results
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_dynamic_logging.py
RENAMED
@@ -39,7 +39,7 @@ def demo_dynamic_config_update():
|
|
39
39
|
# Start with 'simple' logging mode
|
40
40
|
logger = create_default_logger(sql_log_mode='simple')
|
41
41
|
client = Client(logger=logger)
|
42
|
-
client.connect(host, port, user, password, database)
|
42
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
43
43
|
|
44
44
|
# Create test table
|
45
45
|
client.execute("DROP TABLE IF EXISTS dynamic_log_test")
|
@@ -100,7 +100,7 @@ def demo_per_operation_override():
|
|
100
100
|
# Start with 'off' logging mode
|
101
101
|
logger = create_default_logger(sql_log_mode='off')
|
102
102
|
client = Client(logger=logger)
|
103
|
-
client.connect(host, port, user, password, database)
|
103
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
104
104
|
|
105
105
|
# Create test table
|
106
106
|
client.execute("DROP TABLE IF EXISTS override_log_test")
|
@@ -162,7 +162,7 @@ def demo_debugging_scenario():
|
|
162
162
|
# Production setup: minimal logging
|
163
163
|
logger = create_default_logger(sql_log_mode='simple', slow_query_threshold=1.0)
|
164
164
|
client = Client(logger=logger)
|
165
|
-
client.connect(host, port, user, password, database)
|
165
|
+
client.connect(host=host, port=port, user=user, password=password, database=database)
|
166
166
|
|
167
167
|
# Create test table
|
168
168
|
client.execute("DROP TABLE IF EXISTS debug_scenario")
|
@@ -1488,11 +1488,12 @@ class AsyncClient(BaseMatrixOneClient):
|
|
1488
1488
|
|
1489
1489
|
async def connect(
|
1490
1490
|
self,
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1491
|
+
*,
|
1492
|
+
host: str = "localhost",
|
1493
|
+
port: int = 6001,
|
1494
|
+
user: str = "root",
|
1495
|
+
password: str = "111",
|
1496
|
+
database: str,
|
1496
1497
|
account: Optional[str] = None,
|
1497
1498
|
role: Optional[str] = None,
|
1498
1499
|
charset: str = "utf8mb4",
|
@@ -1573,8 +1574,12 @@ class AsyncClient(BaseMatrixOneClient):
|
|
1573
1574
|
|
1574
1575
|
self.logger.log_connection(host, port, final_user, database or "default", success=True)
|
1575
1576
|
|
1576
|
-
# Setup connection hook if provided
|
1577
|
-
|
1577
|
+
# Setup connection hook (default to ENABLE_ALL if not provided)
|
1578
|
+
# Allow empty list [] to explicitly disable hooks
|
1579
|
+
if on_connect is None:
|
1580
|
+
on_connect = [ConnectionAction.ENABLE_ALL]
|
1581
|
+
|
1582
|
+
if on_connect: # Only setup if not empty list
|
1578
1583
|
self._setup_connection_hook(on_connect)
|
1579
1584
|
# Execute the hook once immediately for the initial connection
|
1580
1585
|
await self._execute_connection_hook_immediately(on_connect)
|
@@ -1582,7 +1587,18 @@ class AsyncClient(BaseMatrixOneClient):
|
|
1582
1587
|
except Exception as e:
|
1583
1588
|
self.logger.log_connection(host, port, final_user, database or "default", success=False)
|
1584
1589
|
self.logger.log_error(e, context="Async connection")
|
1585
|
-
|
1590
|
+
|
1591
|
+
# Provide user-friendly error messages for common issues
|
1592
|
+
error_msg = str(e)
|
1593
|
+
if 'Unknown database' in error_msg or '1049' in error_msg:
|
1594
|
+
db_name = database or "default"
|
1595
|
+
raise ConnectionError(
|
1596
|
+
f"Database '{db_name}' does not exist. Please create it first:\n"
|
1597
|
+
f" mysql -h{host} -P{port} -u{user.split('#')[0] if '#' in user else user} -p{password} "
|
1598
|
+
f"-e \"CREATE DATABASE {db_name}\""
|
1599
|
+
) from e
|
1600
|
+
else:
|
1601
|
+
raise ConnectionError(f"Failed to connect to MatrixOne: {e}") from e
|
1586
1602
|
|
1587
1603
|
def _setup_connection_hook(
|
1588
1604
|
self, on_connect: Union[ConnectionHook, List[Union[ConnectionAction, str]], Callable]
|
@@ -244,10 +244,11 @@ class Client(BaseMatrixOneClient):
|
|
244
244
|
|
245
245
|
def connect(
|
246
246
|
self,
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
247
|
+
*,
|
248
|
+
host: str = "localhost",
|
249
|
+
port: int = 6001,
|
250
|
+
user: str = "root",
|
251
|
+
password: str = "111",
|
251
252
|
database: str,
|
252
253
|
ssl_mode: str = "preferred",
|
253
254
|
ssl_ca: Optional[str] = None,
|
@@ -345,8 +346,12 @@ class Client(BaseMatrixOneClient):
|
|
345
346
|
except Exception as e:
|
346
347
|
self.logger.warning(f"Failed to detect backend version: {e}")
|
347
348
|
|
348
|
-
# Setup connection hook if provided
|
349
|
-
|
349
|
+
# Setup connection hook (default to ENABLE_ALL if not provided)
|
350
|
+
# Allow empty list [] to explicitly disable hooks
|
351
|
+
if on_connect is None:
|
352
|
+
on_connect = [ConnectionAction.ENABLE_ALL]
|
353
|
+
|
354
|
+
if on_connect: # Only setup if not empty list
|
350
355
|
self._setup_connection_hook(on_connect)
|
351
356
|
# Execute the hook once immediately for the initial connection
|
352
357
|
self._execute_connection_hook_immediately(on_connect)
|
@@ -354,7 +359,17 @@ class Client(BaseMatrixOneClient):
|
|
354
359
|
except Exception as e:
|
355
360
|
self.logger.log_connection(host, port, final_user, database, success=False)
|
356
361
|
self.logger.log_error(e, context="Connection")
|
357
|
-
|
362
|
+
|
363
|
+
# Provide user-friendly error messages for common issues
|
364
|
+
error_msg = str(e)
|
365
|
+
if 'Unknown database' in error_msg or '1049' in error_msg:
|
366
|
+
raise ConnectionError(
|
367
|
+
f"Database '{database}' does not exist. Please create it first:\n"
|
368
|
+
f" mysql -h{host} -P{port} -u{user.split('#')[0] if '#' in user else user} -p{password} "
|
369
|
+
f"-e \"CREATE DATABASE {database}\""
|
370
|
+
) from e
|
371
|
+
else:
|
372
|
+
raise ConnectionError(f"Failed to connect to MatrixOne: {e}") from e
|
358
373
|
|
359
374
|
def _setup_connection_hook(
|
360
375
|
self, on_connect: Union[ConnectionHook, List[Union[ConnectionAction, str]], Callable]
|
@@ -1686,7 +1701,25 @@ class Client(BaseMatrixOneClient):
|
|
1686
1701
|
from .sqlalchemy_ext import FulltextIndex, VectorIndex
|
1687
1702
|
from sqlalchemy.schema import CreateTable, CreateIndex
|
1688
1703
|
|
1689
|
-
|
1704
|
+
try:
|
1705
|
+
engine_context = self.get_sqlalchemy_engine().begin()
|
1706
|
+
except Exception as e:
|
1707
|
+
# Handle database connection errors with user-friendly messages
|
1708
|
+
error_msg = str(e)
|
1709
|
+
if 'Unknown database' in error_msg or '1049' in error_msg:
|
1710
|
+
db_name = self._connection_params.get('database', 'unknown')
|
1711
|
+
raise ConnectionError(
|
1712
|
+
f"Database '{db_name}' does not exist. Please create it first:\n"
|
1713
|
+
f" mysql -h{self._connection_params.get('host', 'localhost')} "
|
1714
|
+
f"-P{self._connection_params.get('port', 6001)} "
|
1715
|
+
f"-u{self._connection_params.get('user', 'root')} "
|
1716
|
+
f"-p{self._connection_params.get('password', '***')} "
|
1717
|
+
f"-e \"CREATE DATABASE {db_name}\""
|
1718
|
+
) from e
|
1719
|
+
else:
|
1720
|
+
raise ConnectionError(f"Failed to connect to database: {error_msg}") from e
|
1721
|
+
|
1722
|
+
with engine_context as conn:
|
1690
1723
|
# Create table without indexes first
|
1691
1724
|
# Build CREATE TABLE statement without indexes
|
1692
1725
|
create_table_sql = str(CreateTable(table).compile(dialect=conn.dialect))
|
@@ -204,7 +204,9 @@ class RestoreManager:
|
|
204
204
|
result = self._client.execute(sql)
|
205
205
|
return result is not None
|
206
206
|
except Exception as e:
|
207
|
-
raise RestoreError(
|
207
|
+
raise RestoreError(
|
208
|
+
f"Failed to restore database '{database_name}' from snapshot '{snapshot_name}': {e}"
|
209
|
+
) from None
|
208
210
|
|
209
211
|
def restore_table(
|
210
212
|
self,
|
@@ -323,7 +325,9 @@ class RestoreManager:
|
|
323
325
|
)
|
324
326
|
elif restore_type == "table":
|
325
327
|
if not all([account_name, database_name, table_name]):
|
326
|
-
raise RestoreError(
|
328
|
+
raise RestoreError(
|
329
|
+
"Account name, database name, and table name are required for table restore"
|
330
|
+
) from None
|
327
331
|
if to_account:
|
328
332
|
sql = (
|
329
333
|
f"RESTORE ACCOUNT {self._client._escape_identifier(account_name)} "
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1/matrixone_python_sdk.egg-info}/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.1
|
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
|
@@ -185,6 +185,22 @@ print(f"MatrixOne version: {version}")
|
|
185
185
|
client.disconnect()
|
186
186
|
```
|
187
187
|
|
188
|
+
> **📝 Connection Parameters**
|
189
|
+
>
|
190
|
+
> The `connect()` method requires **keyword arguments** (not positional):
|
191
|
+
> - `database` - **Required**, no default value
|
192
|
+
> - `host` - Default: `'localhost'`
|
193
|
+
> - `port` - Default: `6001`
|
194
|
+
> - `user` - Default: `'root'`
|
195
|
+
> - `password` - Default: `'111'`
|
196
|
+
>
|
197
|
+
> **Minimal connection** (uses all defaults):
|
198
|
+
> ```python
|
199
|
+
> client.connect(database='test')
|
200
|
+
> ```
|
201
|
+
>
|
202
|
+
> By default, all features (IVF, HNSW, fulltext) are automatically enabled via `on_connect=[ConnectionAction.ENABLE_ALL]`.
|
203
|
+
|
188
204
|
### Async Usage
|
189
205
|
|
190
206
|
```python
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "matrixone-python-sdk"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.1"
|
8
8
|
description = "A comprehensive Python SDK for MatrixOne database operations with vector search, fulltext search, and advanced features"
|
9
9
|
readme = "README_USER.md"
|
10
10
|
license = {text = "Apache-2.0"}
|
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_12_vector_basics.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_14_vector_search.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_15_vector_advanced.py
RENAMED
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_24_query_update.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_connection_hooks.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/examples/example_ivf_stats_complete.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_metadata_manager.py
RENAMED
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/async_vector_index_manager.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/__init__.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/adapters.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/dialect.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/fulltext_index.py
RENAMED
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/hnsw_config.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/ivf_config.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/table_builder.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/vector_index.py
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone/sqlalchemy_ext/vector_type.py
RENAMED
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/not-zip-safe
RENAMED
File without changes
|
{matrixone_python_sdk-0.1.0 → matrixone_python_sdk-0.1.1}/matrixone_python_sdk.egg-info/requires.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|