Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Manager <> db_cache fix attempt #567

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading