From 32a2684ea26bbd4f514a4866a7e00a8c563cc0ba Mon Sep 17 00:00:00 2001 From: cwilvx Date: Sat, 6 Jul 2024 23:44:24 +0300 Subject: [PATCH] close a connection --- TODO.md | 7 ++++++- app/db/__init__.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 057b7d7d..44b864d0 100644 --- a/TODO.md +++ b/TODO.md @@ -55,4 +55,9 @@ - Create 2 way relationships, such that if an artist A is similar to another B with a certain weight, then artist B is similar to A with the same weight, unless overwritten. - Figure out how to update album/artist tables instead of deleting all rows when the app starts -- Move get all filtering and sorting operations to the database since all sort keys are table columns \ No newline at end of file +- Move get all filtering and sorting operations to the database since all sort keys are table columns + +- Paginate the following endpoints: + 1. Folder tracks + 2. Playlist tracks + \ No newline at end of file diff --git a/app/db/__init__.py b/app/db/__init__.py index 4f7fb524..e6d1cc54 100644 --- a/app/db/__init__.py +++ b/app/db/__init__.py @@ -12,6 +12,7 @@ from sqlalchemy import event from sqlalchemy.orm import ( DeclarativeBase, MappedAsDataclass, + Session ) from app.db.engine import DbEngine @@ -27,6 +28,8 @@ class DbManager: def __init__(self, commit: bool = False): self.commit = commit self.conn = DbEngine.engine.connect() + with Session(DbEngine.engine) as session: + session.connection def __enter__(self): return self.conn.execution_options(preserve_rowcount=True) @@ -35,7 +38,7 @@ class DbManager: if self.commit: self.conn.commit() - # self.conn.close() + self.conn.close() class Base(MappedAsDataclass, DeclarativeBase):