sunholo 0.127.1__py3-none-any.whl → 0.127.2__py3-none-any.whl
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.
- sunholo/database/alloydb_client.py +10 -6
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/METADATA +1 -1
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/RECORD +7 -7
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/WHEEL +0 -0
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/entry_points.txt +0 -0
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/licenses/LICENSE.txt +0 -0
- {sunholo-0.127.1.dist-info → sunholo-0.127.2.dist-info}/top_level.txt +0 -0
@@ -823,7 +823,7 @@ class AlloyDBClient:
|
|
823
823
|
return await self._insert_single_row(table_name, regular_data, metadata)
|
824
824
|
|
825
825
|
|
826
|
-
async def _insert_single_row(self, table_name: str, data: dict, metadata: dict = None):
|
826
|
+
async def _insert_single_row(self, table_name: str, data: dict, metadata: dict = None, primary_key_column:str = "id"):
|
827
827
|
"""
|
828
828
|
Inserts a single row of data into the specified table.
|
829
829
|
|
@@ -869,7 +869,7 @@ class AlloyDBClient:
|
|
869
869
|
sql = f'''
|
870
870
|
INSERT INTO "{table_name}" ({columns_str})
|
871
871
|
VALUES ({placeholders_str})
|
872
|
-
RETURNING
|
872
|
+
RETURNING {primary_key_column}
|
873
873
|
'''
|
874
874
|
|
875
875
|
# Execute SQL to insert data based on engine type
|
@@ -1075,7 +1075,8 @@ class AlloyDBClient:
|
|
1075
1075
|
log.debug(f"Conversion error for value '{value}' to {target_type}: {e}")
|
1076
1076
|
return None
|
1077
1077
|
|
1078
|
-
async def insert_rows_safely(self, table_name, rows, metadata=None, continue_on_error=False
|
1078
|
+
async def insert_rows_safely(self, table_name, rows, metadata=None, continue_on_error=False, primary_key_column="id" # Specify the correct primary key column here
|
1079
|
+
):
|
1079
1080
|
"""
|
1080
1081
|
Insert multiple rows into a table with error handling for individual rows.
|
1081
1082
|
|
@@ -1084,6 +1085,7 @@ class AlloyDBClient:
|
|
1084
1085
|
rows (list): List of dictionaries containing row data
|
1085
1086
|
metadata (dict, optional): Additional metadata to include in each row
|
1086
1087
|
continue_on_error (bool): Whether to continue if some rows fail
|
1088
|
+
primary_key_column (str): The primary key in the table, default 'id'
|
1087
1089
|
|
1088
1090
|
Returns:
|
1089
1091
|
dict: {
|
@@ -1136,7 +1138,7 @@ class AlloyDBClient:
|
|
1136
1138
|
filtered_row[col_name] = value
|
1137
1139
|
|
1138
1140
|
# Insert the row
|
1139
|
-
result = await self._insert_single_row(table_name, filtered_row)
|
1141
|
+
result = await self._insert_single_row(table_name, filtered_row, primary_key_column=primary_key_column)
|
1140
1142
|
results['inserted_rows'] += 1
|
1141
1143
|
|
1142
1144
|
except Exception as e:
|
@@ -1158,7 +1160,7 @@ class AlloyDBClient:
|
|
1158
1160
|
results['success'] = results['inserted_rows'] > 0
|
1159
1161
|
return results
|
1160
1162
|
|
1161
|
-
async def create_table_with_columns(self, table_name, column_definitions, if_not_exists=True):
|
1163
|
+
async def create_table_with_columns(self, table_name, column_definitions, if_not_exists=True, primary_key_column="id"):
|
1162
1164
|
"""
|
1163
1165
|
Create a table with explicit column definitions.
|
1164
1166
|
|
@@ -1171,6 +1173,8 @@ class AlloyDBClient:
|
|
1171
1173
|
- default: Default value expression (optional)
|
1172
1174
|
- primary_key: Whether this is a primary key (default False)
|
1173
1175
|
if_not_exists (bool): Whether to use IF NOT EXISTS clause
|
1176
|
+
primary_key_column (str): default name of primary key if not specified in column_definitions
|
1177
|
+
|
1174
1178
|
|
1175
1179
|
Returns:
|
1176
1180
|
Result of the execution
|
@@ -1186,7 +1190,7 @@ class AlloyDBClient:
|
|
1186
1190
|
|
1187
1191
|
if not has_primary_key:
|
1188
1192
|
# Add an ID column as primary key
|
1189
|
-
column_strs.append("
|
1193
|
+
column_strs.append(f'"{primary_key_column}" SERIAL PRIMARY KEY')
|
1190
1194
|
|
1191
1195
|
for col in column_definitions:
|
1192
1196
|
col_name = col.get('name')
|
@@ -60,7 +60,7 @@ sunholo/components/retriever.py,sha256=Wmchv3huAM4w7DIS-a5Lp9Hi7M8pE6vZdxgseiT9S
|
|
60
60
|
sunholo/components/vectorstore.py,sha256=k7GS1Y5c6ZGXSDAJvyCes6dTjhDAi0fjGbVLqpyfzBc,5918
|
61
61
|
sunholo/database/__init__.py,sha256=bpB5Nk21kwqYj-qdVnvNgXjLsbflnH4g-San7OHMqR4,283
|
62
62
|
sunholo/database/alloydb.py,sha256=x1zUMB-EVWbE2Zvp4nAs2Z-tB_kOZmS45H2lwVHdYnk,11678
|
63
|
-
sunholo/database/alloydb_client.py,sha256=
|
63
|
+
sunholo/database/alloydb_client.py,sha256=bVP91jz6gizJrzgAize5EIx64htHybDVN9UGZpGSXi4,50703
|
64
64
|
sunholo/database/database.py,sha256=VqhZdkXUNdvWn8sUcUV3YNby1JDVf7IykPVXWBtxo9U,7361
|
65
65
|
sunholo/database/lancedb.py,sha256=DyfZntiFKBlVPaFooNN1Z6Pl-LAs4nxWKKuq8GBqN58,715
|
66
66
|
sunholo/database/static_dbs.py,sha256=8cvcMwUK6c32AS2e_WguKXWMkFf5iN3g9WHzsh0C07Q,442
|
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
168
168
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
169
169
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
170
170
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
171
|
-
sunholo-0.127.
|
172
|
-
sunholo-0.127.
|
173
|
-
sunholo-0.127.
|
174
|
-
sunholo-0.127.
|
175
|
-
sunholo-0.127.
|
176
|
-
sunholo-0.127.
|
171
|
+
sunholo-0.127.2.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
172
|
+
sunholo-0.127.2.dist-info/METADATA,sha256=vflFwcPWETDwMH45GRhr5McMoghZpm8-hspdiP3qNZs,10084
|
173
|
+
sunholo-0.127.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
174
|
+
sunholo-0.127.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
175
|
+
sunholo-0.127.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
176
|
+
sunholo-0.127.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|