app/models/postgresql_base_model.py
@@ -7,11 +7,15 @@ DATABASE_URL = os.getenv('POSTGRESQL_DATABASE_URL') or settings.postgresql_database_url engine = create_async_engine(DATABASE_URL, echo=True) engine = create_async_engine(DATABASE_URL, echo=False) PostgresqlSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine, class_=AsyncSession) PostgresqlBase = declarative_base() async def get_pdb() -> AsyncSession: async with PostgresqlSessionLocal() as session: yield session # yield session try: yield session finally: session.close()