Skip to content

✨ Add Engine class re-export from SQLAlchemy#1981

Closed
AlefRP wants to merge 1 commit into
fastapi:mainfrom
AlefRP:feature/add-engine-class
Closed

✨ Add Engine class re-export from SQLAlchemy#1981
AlefRP wants to merge 1 commit into
fastapi:mainfrom
AlefRP:feature/add-engine-class

Conversation

@AlefRP
Copy link
Copy Markdown

@AlefRP AlefRP commented May 24, 2026

Pull Request

Description

This PR re-exports SQLAlchemy's Engine class from the top-level sqlmodel
namespace, alongside the already-exported create_engine, create_mock_engine
and engine_from_config.

This makes it possible to import Engine directly from sqlmodel and use it
for type hints when writing your own engine/session helpers, mirroring how
SQLAlchemy exposes it:

from sqlmodel import Engine, create_engine, Session

def make_engine(url: str) -> Engine:
    return create_engine(url)

def get_session(engine: Engine) -> Session:
    return Session(engine)

The export is added next to the other sqlalchemy.engine imports in
sqlmodel/init.py, following the existing import X as X re-export
convention used throughout the file (so it is picked up as public API by type
checkers and linters).

Checklist

  • This PR is an obvious typo fix, or it links to a GitHub Discussion for the proposed code change.
  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.
  • The documentation explains the change if needed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@AlefRP
Copy link
Copy Markdown
Author

AlefRP commented May 24, 2026

Please add the feature label to pass the label check workflow.

@YuriiMotov YuriiMotov closed this May 25, 2026
@YuriiMotov
Copy link
Copy Markdown
Member

I think we should do it in a more complex way - add not just Engine, but other missing re-exports as well.

Let's start from discussion as it's asked in the PR template

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.

3 participants