MCPcopy Index your code
hub / github.com/reflex-dev/reflex / asession

Function asession

reflex/model.py:691–714  ·  view source on GitHub ↗

Get an async sqlmodel session to interact with the database. async with rx.asession() as asession: ... Most operations against the `asession` must be awaited. Args: url: The database url. Returns: An async database session.

(url: str | None = None)

Source from the content-addressed store, hash-verified

689 return sqlmodel.Session(get_engine(url))
690
691 def asession(url: str | None = None) -> AsyncSession:
692 """Get an async sqlmodel session to interact with the database.
693
694 async with rx.asession() as asession:
695 ...
696
697 Most operations against the `asession` must be awaited.
698
699 Args:
700 url: The database url.
701
702 Returns:
703 An async database session.
704 """
705 global _AsyncSessionLocal
706 if url not in _AsyncSessionLocal:
707 _AsyncSessionLocal[url] = sqlalchemy.ext.asyncio.async_sessionmaker(
708 bind=get_async_engine(url),
709 class_=AsyncSession,
710 expire_on_commit=False,
711 autocommit=False,
712 autoflush=False,
713 )
714 return _AsyncSessionLocal[url]()
715
716else:
717 get_db_status = _print_db_not_available

Callers

nothing calls this directly

Calls 1

get_async_engineFunction · 0.85

Tested by

no test coverage detected