sunholo 0.83.2__py3-none-any.whl → 0.83.4__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.
@@ -72,15 +72,18 @@ class AlloyDBClient:
72
72
 
73
73
  self.database = alloydb_config.get("database") or ALLOYDB_DB
74
74
 
75
+ self.user = user
76
+ self.password = password
77
+ self.inst_url = ""
75
78
  if user:
76
79
  log.info("User specified {user} - using pg8000 engine")
77
- self.user = user
78
- self.password = password
79
80
  self.inst_url = self._build_instance_uri(project_id, region, cluster_name, instance_name)
80
81
  self.engine = self._create_engine_from_pg8000()
82
+ self.engine_type = "pg8000"
81
83
  else:
82
84
  log.info("Build with Langchain engine - will use default service account for auth")
83
85
  self.engine = self._create_engine()
86
+ self.engine_type = "langchain"
84
87
 
85
88
  def _build_instance_uri(self, project_id, region, cluster_name, instance_name):
86
89
  return f"projects/{project_id}/locations/{region}/clusters/{cluster_name}/instances/{instance_name}"
@@ -119,7 +122,6 @@ class AlloyDBClient:
119
122
  region=self.config["region"],
120
123
  cluster=self.config["cluster"],
121
124
  instance=self.config["instance"],
122
- user=self.user,
123
125
  password=self.password,
124
126
  database=self.database,
125
127
  ip_type=self.config.get("ip_type") or IPTypes.PRIVATE
@@ -128,8 +130,17 @@ class AlloyDBClient:
128
130
  log.info(f"Created AlloyDB engine for {engine}")
129
131
 
130
132
  return engine
131
-
133
+
132
134
  def execute_sql(self, sql_statement):
135
+ if self.engine_type == "pg8000":
136
+ return self._execute_sql_pg8000(sql_statement)
137
+ elif self.engine_type == "langchain":
138
+ return self._execute_sql_langchain(sql_statement)
139
+
140
+ def _execute_sql_langchain(self, sql_statement):
141
+ return self.engine._fetch(query = sql_statement)
142
+
143
+ def _execute_sql_pg8000(self, sql_statement):
133
144
  """Executes a given SQL statement with error handling.
134
145
 
135
146
  - sql_statement (str): The SQL statement to execute.
@@ -152,6 +163,17 @@ class AlloyDBClient:
152
163
  return result
153
164
 
154
165
  async def execute_sql_async(self, sql_statement):
166
+ if self.engine_type == "pg8000":
167
+ result = await self._execute_sql_async_pg8000(sql_statement)
168
+ elif self.engine_type == "langchain":
169
+ result = await self._execute_sql_async_langchain(sql_statement)
170
+
171
+ return result
172
+
173
+ async def _execute_sql_async_langchain(self, sql_statement):
174
+ return await self.engine._afetch(query = sql_statement)
175
+
176
+ async def _execute_sql_async_pg8000(self, sql_statement):
155
177
  """Executes a given SQL statement asynchronously with error handling."""
156
178
  sql_ = sqlalchemy.text(sql_statement)
157
179
  result = None
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.83.2
3
+ Version: 0.83.4
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Home-page: https://github.com/sunholo-data/sunholo-py
6
- Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.83.2.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.83.4.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -59,7 +59,7 @@ sunholo/components/retriever.py,sha256=bKIVT7_18Ut3OJd0E0jyiISPnD9qkHWVjcQPT4i1_
59
59
  sunholo/components/vectorstore.py,sha256=xKk7micTRwZckaI7U6PxvFz_ZSjCH48xPTDYiDcv2tc,5913
60
60
  sunholo/database/__init__.py,sha256=bpB5Nk21kwqYj-qdVnvNgXjLsbflnH4g-San7OHMqR4,283
61
61
  sunholo/database/alloydb.py,sha256=YH8wNPS8gN-TDZEXQcVHxwd1NScHRfAxma3gK4R6KCk,11740
62
- sunholo/database/alloydb_client.py,sha256=xqXhzHoh0e5RKz0wc7MwCayL89JdrYG016Oq-ZSNfBc,12731
62
+ sunholo/database/alloydb_client.py,sha256=Ws_GfoST_WHqq7iISW06dqFeOnfbjdPaEl9qNm3cGEc,13651
63
63
  sunholo/database/database.py,sha256=VqhZdkXUNdvWn8sUcUV3YNby1JDVf7IykPVXWBtxo9U,7361
64
64
  sunholo/database/lancedb.py,sha256=DyfZntiFKBlVPaFooNN1Z6Pl-LAs4nxWKKuq8GBqN58,715
65
65
  sunholo/database/static_dbs.py,sha256=8cvcMwUK6c32AS2e_WguKXWMkFf5iN3g9WHzsh0C07Q,442
@@ -134,9 +134,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
134
134
  sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
135
135
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
136
136
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
137
- sunholo-0.83.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
- sunholo-0.83.2.dist-info/METADATA,sha256=L_LY3La6qhCknE_-6il21csG0OjyiikTyiPiJTx2EQQ,7413
139
- sunholo-0.83.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
- sunholo-0.83.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
- sunholo-0.83.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
- sunholo-0.83.2.dist-info/RECORD,,
137
+ sunholo-0.83.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
138
+ sunholo-0.83.4.dist-info/METADATA,sha256=5ET_6DFTvDaLytFoVb5we2TYf0vMyhK657U1MYmTm0o,7413
139
+ sunholo-0.83.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
140
+ sunholo-0.83.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
141
+ sunholo-0.83.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
142
+ sunholo-0.83.4.dist-info/RECORD,,