Skip to content

Export AsyncSession from sqlmodel.ext.asyncio module#1749

Open
veeceey wants to merge 1 commit intofastapi:mainfrom
veeceey:fix/export-async-session
Open

Export AsyncSession from sqlmodel.ext.asyncio module#1749
veeceey wants to merge 1 commit intofastapi:mainfrom
veeceey:fix/export-async-session

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 8, 2026

Summary

Added export for AsyncSession from the sqlmodel.ext.asyncio module to make it more discoverable and easier to import.

Problem

AsyncSession was defined in sqlmodel/ext/asyncio/session.py but not exported from the module's __init__.py. This required users to know the exact file path and use a longer import statement.

Changes

Added from .session import AsyncSession as AsyncSession to sqlmodel/ext/asyncio/__init__.py

Benefits

Before this change:

from sqlmodel.ext.asyncio.session import AsyncSession  # Longer, less discoverable

After this change:

from sqlmodel.ext.asyncio import AsyncSession  # Cleaner, more intuitive

This makes the async API more consistent with how Session is exported from sqlmodel.orm.

Test plan

  • ✅ Verified import works: from sqlmodel.ext.asyncio import AsyncSession
  • ✅ Existing tests pass
  • No functional changes, only improved import ergonomics

Related

This follows Python best practices for package structure and makes SQLModel's async support easier to discover for users coming from the documentation.

AsyncSession was defined in sqlmodel/ext/asyncio/session.py but not exported
from the module's __init__.py, requiring users to use the longer import path.

Before:
  from sqlmodel.ext.asyncio.session import AsyncSession

After:
  from sqlmodel.ext.asyncio import AsyncSession

This makes the async API more discoverable and consistent with how Session
is exported from sqlmodel.orm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant