From b3216486c417f7fb2abc0724563a1d21f9a835d9 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 5 May 2023 11:50:29 -0400 Subject: add AsyncAttrs Added a new helper mixin :class:`_asyncio.AsyncAttrs` that seeks to improve the use of lazy-loader and other expired or deferred ORM attributes with asyncio, providing a simple attribute accessor that provides an ``await`` interface to any ORM attribute, whether or not it needs to emit SQL. Change-Id: I1427b288dc28319c854372643066c491b9ee8dc0 References: #9731 --- examples/asyncio/greenlet_orm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'examples/asyncio/greenlet_orm.py') diff --git a/examples/asyncio/greenlet_orm.py b/examples/asyncio/greenlet_orm.py index 7429b6853..92880b992 100644 --- a/examples/asyncio/greenlet_orm.py +++ b/examples/asyncio/greenlet_orm.py @@ -10,13 +10,16 @@ from sqlalchemy import Column from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import String +from sqlalchemy.ext.asyncio import AsyncAttrs from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import create_async_engine -from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.future import select +from sqlalchemy.orm import DeclarativeBase from sqlalchemy.orm import relationship -Base = declarative_base() + +class Base(AsyncAttrs, DeclarativeBase): + pass class A(Base): -- cgit v1.2.1