Skip to content

Commit

Permalink
DB Manager <> db_cache fix attempt (#567)
Browse files Browse the repository at this point in the history
* Reduced pool size | passed connection instead of engine

* Added missing commit

* Removed comment for deploying
  • Loading branch information
gabrielfior authored Dec 4, 2024
1 parent 05869ef commit beacb48
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions prediction_market_agent_tooling/tools/db/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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:
Expand All @@ -68,7 +67,9 @@ 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)
connection.commit()

# Update cache to mark tables as initialized
if tables_to_create:
Expand Down

0 comments on commit beacb48

Please sign in to comment.