close a connection

This commit is contained in:
cwilvx
2024-07-06 23:44:24 +03:00
parent 104ef4c346
commit 32a2684ea2
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -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
- 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
+4 -1
View File
@@ -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):