(20250107) Added connection closing method to AsyncMySQL.

This commit is contained in:
2025-01-07 13:33:40 +05:30
parent ac7407cfba
commit b20d4850c2
+16 -1
View File
@@ -154,6 +154,21 @@ class AsyncMySQL:
# Done here:
return False if self.__pool is None else True
async def disconnect(self) -> bool:
try:
# Try to close the pool and wait for the process to complete:
self.__pool.close()
await self.__pool.wait_closed()
# In case of any exception:
except Exception as exception:
self.__printer(exception)
# Done here:
return False if self.__pool is None else True
async def ensure_connection(self):
"""
@@ -361,7 +376,7 @@ class AsyncMySQL:
async def execute_many(
self,
query: str,
data: List[tuple],
data: List[tuple | List],
commit: bool = True,
return_exception: bool = False
):