I get AttributeError: __aenter__
error using session like this:
<code> async def get_session():
SessionLocal = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine,
expire_on_commit=False,
class_=AsyncSession,
)
async with SessionLocal() as session:
yield session
async def insert(data_array):
async with get_session() as session:
session.add_all(data_array)
await session.commit()
await insert(reports)
</code>
<code> async def get_session():
SessionLocal = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine,
expire_on_commit=False,
class_=AsyncSession,
)
async with SessionLocal() as session:
yield session
async def insert(data_array):
async with get_session() as session:
session.add_all(data_array)
await session.commit()
await insert(reports)
</code>
async def get_session():
SessionLocal = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine,
expire_on_commit=False,
class_=AsyncSession,
)
async with SessionLocal() as session:
yield session
async def insert(data_array):
async with get_session() as session:
session.add_all(data_array)
await session.commit()
await insert(reports)
error occurs here async with get_session() as _session:
in debugger get_session()
is generator as it supposed to be, i guess, but no __aenter__
attribute inside
I am using asyncio, connected database is postgres
My sqlalchemy version is 2.0.28
I have tried some changes in sessionmaker
but it didn’t give any results