From 73a31f38e9d10876bb650826b584ab154d8b1c93 Mon Sep 17 00:00:00 2001 From: gabrielfior Date: Tue, 3 Dec 2024 18:10:52 -0300 Subject: [PATCH 1/3] Reduced pool size | passed connection instead of engine --- prediction_market_agent_tooling/tools/db/db_manager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prediction_market_agent_tooling/tools/db/db_manager.py b/prediction_market_agent_tooling/tools/db/db_manager.py index f794f0a3..6165dcea 100644 --- a/prediction_market_agent_tooling/tools/db/db_manager.py +++ b/prediction_market_agent_tooling/tools/db/db_manager.py @@ -33,7 +33,7 @@ def __init__(self, api_keys: APIKeys | None = None) -> None: sqlalchemy_db_url.get_secret_value(), json_serializer=json_serializer, json_deserializer=json_deserializer, - pool_size=20, + pool_size=10, pool_recycle=3600, echo=True, ) @@ -68,7 +68,8 @@ def create_tables( tables_to_create = None # Create tables in the database - SQLModel.metadata.create_all(self._engine, tables=tables_to_create) + with self.get_connection() as connection: + SQLModel.metadata.create_all(connection, tables=tables_to_create) # Update cache to mark tables as initialized if tables_to_create: From 692d15cbe58def5edd4555d28cd61e8c4d023472 Mon Sep 17 00:00:00 2001 From: gabrielfior Date: Wed, 4 Dec 2024 15:35:29 -0300 Subject: [PATCH 2/3] Added missing commit --- prediction_market_agent_tooling/tools/db/db_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/prediction_market_agent_tooling/tools/db/db_manager.py b/prediction_market_agent_tooling/tools/db/db_manager.py index 6165dcea..0fcaece5 100644 --- a/prediction_market_agent_tooling/tools/db/db_manager.py +++ b/prediction_market_agent_tooling/tools/db/db_manager.py @@ -70,6 +70,7 @@ def create_tables( # Create tables in the database with self.get_connection() as connection: SQLModel.metadata.create_all(connection, tables=tables_to_create) + connection.commit() # Update cache to mark tables as initialized if tables_to_create: From 29c17b80fb8381bb51a750b33d162ee1a46721d9 Mon Sep 17 00:00:00 2001 From: gabrielfior Date: Wed, 4 Dec 2024 15:46:23 -0300 Subject: [PATCH 3/3] Removed comment for deploying --- prediction_market_agent_tooling/tools/db/db_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/prediction_market_agent_tooling/tools/db/db_manager.py b/prediction_market_agent_tooling/tools/db/db_manager.py index 0fcaece5..3ef8f1fb 100644 --- a/prediction_market_agent_tooling/tools/db/db_manager.py +++ b/prediction_market_agent_tooling/tools/db/db_manager.py @@ -52,7 +52,6 @@ def get_connection(self) -> Generator[Connection, None, None]: def create_tables( self, sqlmodel_tables: Sequence[type[SQLModel]] | None = None ) -> None: - # Determine tables to create if sqlmodel_tables is not None: tables_to_create = [] for sqlmodel_table in sqlmodel_tables: