mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 23:23:25 +02:00
refactor: reformat code
This commit is contained in:
@@ -12,8 +12,19 @@ from backend.src.database.config import DbConfig
|
||||
log = logging.getLogger(__name__)
|
||||
config = DbConfig()
|
||||
|
||||
db_url = "postgresql+psycopg" + "://" + config.USER + ":" + config.PASSWORD + "@" + config.HOST + ":" + str(
|
||||
config.PORT) + "/" + config.DBNAME
|
||||
db_url = (
|
||||
"postgresql+psycopg"
|
||||
+ "://"
|
||||
+ config.USER
|
||||
+ ":"
|
||||
+ config.PASSWORD
|
||||
+ "@"
|
||||
+ config.HOST
|
||||
+ ":"
|
||||
+ str(config.PORT)
|
||||
+ "/"
|
||||
+ config.DBNAME
|
||||
)
|
||||
|
||||
engine = create_engine(db_url, echo=False)
|
||||
log.debug("initializing sqlalchemy declarative base")
|
||||
@@ -21,7 +32,6 @@ Base = declarative_base()
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
log.debug("initializing database with following tables")
|
||||
for table in Base.metadata.tables:
|
||||
@@ -41,7 +51,7 @@ def get_session() -> Generator[Session, Any, None]:
|
||||
db.close()
|
||||
|
||||
|
||||
db_session: ContextVar[Session] = ContextVar('db_session')
|
||||
db_session: ContextVar[Session] = ContextVar("db_session")
|
||||
|
||||
|
||||
DbSessionDependency = Annotated[Session, Depends(get_session)]
|
||||
|
||||
Reference in New Issue
Block a user