{"id":20964,"library":"atlas-provider-sqlalchemy","title":"Atlas Provider SQLAlchemy","description":"Load SQLAlchemy models into an Atlas project for schema migration inspection and planning. Compatible with SQLAlchemy 1.4+ and 2.0+. Currently at version 0.5.0, released monthly.","status":"active","version":"0.5.0","language":"python","source_language":"en","source_url":"https://github.com/ariga/atlas-provider-sqlalchemy","tags":["atlas","sqlalchemy","database","migration"],"install":[{"cmd":"pip install atlas-provider-sqlalchemy","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core dependency to load models.","package":"sqlalchemy","optional":false},{"reason":"Required to interface with Atlas CLI.","package":"atlas-sdk","optional":false}],"imports":[{"note":"Older versions had a different module path; always import from top-level.","wrong":"from atlas_provider_sqlalchemy.dsl import get_provider","symbol":"get_provider","correct":"from atlas_provider_sqlalchemy import get_provider"}],"quickstart":{"code":"import os\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.orm import declarative_base\nfrom atlas_provider_sqlalchemy import get_provider\n\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    name = Column(String(50))\n\n# Use a sample URL; in production, set via environment variable\nengine = create_engine(os.environ.get('DATABASE_URL', 'sqlite:///:memory:'))\nBase.metadata.create_all(engine)\n\nprovider = get_provider(Base.metadata)\nprint(provider.schema)  # Prints the schema as HCL for Atlas","lang":"python","description":"Creates an Atlas provider from a SQLAlchemy declarative base."},"warnings":[{"fix":"Use `get_provider(Base.metadata)` instead of `get_provider(engine)`.","message":"In version 0.4.0, the function signature changed from `get_provider(engine)` to `get_provider(metadata)`. Directly passing an engine will raise a TypeError.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure all model classes inherit from the same declarative base instance.","message":"The provider only reflects tables defined in the passed metadata object. If you have models imported but not associated with a common Base, they will be missing.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `Base.metadata` that includes all model classes.","message":"Atlas expects a single HCL schema file. Multiple providers or multiple metadata objects are not supported. Merge all models into one metadata.","severity":"gotcha","affected_versions":"all"},{"fix":"Uninstall the old package and install `atlas-provider-sqlalchemy`.","message":"The `atlas-provider-sqlalchemy` package was previously named `ariga-atlas-provider-sqlalchemy`. The old package is deprecated and will not receive updates.","severity":"deprecated","affected_versions":"<0.3.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `get_provider(Base.metadata)`.","cause":"Calling get_provider(engine) instead of get_provider(metadata) after version 0.4.0.","error":"TypeError: get_provider() missing 1 required positional argument: 'metadata'"},{"fix":"Use `from atlas_provider_sqlalchemy import get_provider`.","cause":"Importing from a submodule that no longer exists in newer versions.","error":"ModuleNotFoundError: No module named 'atlas_provider_sqlalchemy.dsl'"},{"fix":"Add `from sqlalchemy import Column, Integer, String` to your model definitions.","cause":"Forgot to import Column and Integer from sqlalchemy in the model file.","error":"sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper|User|users, expression 'Column' is not a valid attribute name"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}