Skip to content

Document relevant asyncio notes for SQLAlchemy #26

Description

@devraj

When using asyncio - queries etc use the new 2.0 query pattern e.g

    @classmethod
    async def get_active_for_facility(cls, async_db_session, facility_id):
        query = select(cls).options(selectinload(cls.products)).\
            where(cls.facility_id == facility_id).\
            where(cls.active == True)
        results = await async_db_session.execute(query)
        (result,) =  results.scalars().all()
        return result

which also means using statements like select(cls).options(selectinload(cls.products)) to load the children. This is required when we are trying to include these objects as part of the API results.

While SQLAlchemy has extensive documentation about this we should extract our some useful tips and tricks to speed up the learning process, current hit list

Activity

  1. self-assigned this
    on Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions