sqlalchemy

SQLAlchemy connection configuration for universal database access.

class mcp_ohmy_sql.config.sqlalchemy.SqlalchemyConnection(*, type: ~typing.Literal['sqlalchemy'] = 'sqlalchemy', url: str | None = None, drivername: str | None = None, username: str | None = None, password: str | None = None, host: str | None = None, port: int | None = None, database: str | None = None, query: ~typing.Mapping[str, ~typing.Sequence[str] | str] | None = None, create_engine_kwargs: dict[str, ~typing.Any] = <factory>)[source]

Configures SQLAlchemy connections to support any SQL database.

Provides three connection methods:

Parameters:
  • type – DO NOT set this field manually, it is automatically set to “sqlalchemy”.

  • url – hard-coded connection URL, e.g., “sqlite:///path/to/db.sqlite”, see: https://docs.sqlalchemy.org/en/20/core/engines.html

The following are sqlalchemy.URL parameters, which can be used to construct the URL dynamically: https://docs.sqlalchemy.org/en/20/core/engines.html#creating-urls-programmatically

Parameters:
  • drivername – a URL class parameter

  • username – a URL class parameter

  • password – a URL class parameter

  • host – a URL class parameter

  • port – a URL class parameter

  • database – a URL class parameter

  • query – a URL class parameter

  • create_engine_kwargs – additional keyword arguments for sa.create_engine()

property sa_engine: Engine

Create a SQLAlchemy engine using the provided URL and additional parameters.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].