Skip to content

[FEATURE] Make sqlalchemy an optional dependency #228

@johnthagen

Description

@johnthagen

Is your feature request related to a problem? Please describe.

We use fastapi_utils.InferringRouter on a lot of projects to enable more natural use of type annotations within FastAPI. On some of these projects, there is no database usage at all or even a different database type all together, such as MongoDB.

We'd like to avoid the need of installing sqlalchemy (and its dependency greenlet) in these situations, which makes the Docker images larger and is one more package we need to track for updates and audit.

Describe the solution you'd like

Be able to install fastapi-utils in two ways:

$ pip install fastapi-utils
# This depends only on fastapi and pydantic
$ pip install fastapi[sqlalchemy]
# This additionally installs the extra-requires sqlalchemy

Additional context

In Poetry, use the extras keyword to accomplish this: https://python-poetry.org/docs/pyproject/#extras

Setuptools docs on optional dependencies: https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#optional-dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions