sunholo 0.123.0__py3-none-any.whl → 0.123.1__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.
@@ -531,6 +531,60 @@ class AlloyDBClient:
531
531
 
532
532
  return await self.engine._afetch(query=sql_statement)
533
533
 
534
+ async def check_connection(self):
535
+ """
536
+ Checks if the database connection is still valid.
537
+
538
+ Returns:
539
+ bool: True if connection is valid, False otherwise
540
+ """
541
+ try:
542
+ # Simple query to check connection
543
+ result = await self.execute_sql_async("SELECT 1")
544
+ return True
545
+ except Exception as e:
546
+ log.warning(f"Database connection check failed: {e}")
547
+ return False
548
+
549
+ async def ensure_connected(self):
550
+ """
551
+ Ensures the database connection is valid, attempting to reconnect if necessary.
552
+
553
+ Returns:
554
+ bool: True if connection is valid or reconnection successful, False otherwise
555
+ """
556
+ if await self.check_connection():
557
+ return True
558
+
559
+ try:
560
+ # Attempt to reconnect - implementation depends on your database driver
561
+ if self.engine_type == "pg8000":
562
+ # Re-create the engine
563
+ self.engine = self._create_engine_from_pg8000(self.user, self.password, self.database)
564
+ elif self.engine_type == "langchain":
565
+ # Re-create the engine
566
+ self.engine = self._create_engine()
567
+
568
+ log.info(f"Successfully reconnected to AlloyDB")
569
+ return True
570
+ except Exception as e:
571
+ log.error(f"Failed to reconnect to AlloyDB: {e}")
572
+ return False
573
+
574
+ async def close(self):
575
+ """
576
+ Properly close the database connection.
577
+ """
578
+ try:
579
+ if self.engine_type == "pg8000":
580
+ # Close engine or connector
581
+ if hasattr(self, 'connector'):
582
+ await self.connector.close()
583
+ # For langchain engine, additional cleanup might be needed
584
+ log.info("Closed AlloyDB connection")
585
+ except Exception as e:
586
+ log.warning(f"Error closing AlloyDB connection: {e}")
587
+
534
588
  async def create_table_from_schema(self, table_name: str, schema_data: dict, users: list = None):
535
589
  """
536
590
  Creates or ensures a table exists based on the structure of the provided schema data.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.123.0
3
+ Version: 0.123.1
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -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=uUJN-FYPmGAb9rzGVdg7ds38YhwKBQCXPqUtdOzBQCg,25123
63
+ sunholo/database/alloydb_client.py,sha256=WpkrQmy2hK4148df-6Ys8XRjCGpObZa9Dc9TXLSX_sE,27108
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.123.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
- sunholo-0.123.0.dist-info/METADATA,sha256=ue-wXoQBj7xkEm3nzOg0to1O3counnyi7K3RJfzcv0M,10001
173
- sunholo-0.123.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
174
- sunholo-0.123.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
- sunholo-0.123.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
- sunholo-0.123.0.dist-info/RECORD,,
171
+ sunholo-0.123.1.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
+ sunholo-0.123.1.dist-info/METADATA,sha256=eMkSTIyICC03RID4bD6yN7ryL8Faglbjjj2EKsnvVf4,10001
173
+ sunholo-0.123.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
174
+ sunholo-0.123.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
+ sunholo-0.123.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
+ sunholo-0.123.1.dist-info/RECORD,,