{"record":{"id":"3553116cdbc1b9ef","repo":"tursodatabase/turso","slug":"pyturso-s-sqlalchemy-dialects-require-sqlalchemy","errorCode":null,"errorMessage":"pyturso's SQLAlchemy dialects require SQLAlchemy >= 2.0.45 (found {sqlalchemy.__version__}). Upgrade with: pip install 'sqlalchemy>=2.0.45'","messagePattern":"pyturso's SQLAlchemy dialects require SQLAlchemy >= 2\\.0\\.45 \\(found (.+?)\\)\\. Upgrade with: pip install 'sqlalchemy>=2\\.0\\.45'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"bindings/python/turso/sqlalchemy/__init__.py","lineNumber":45,"sourceCode":"        sync.pull()  # Pull remote changes\n        result = conn.execute(text(\"SELECT * FROM users\"))\n        conn.commit()\n        sync.push()  # Push local changes\n\"\"\"\n\nimport re\n\nimport sqlalchemy\n\n# SQLAlchemy 2.0.42 first shipped AsyncAdapt_dbapi_module (imported by .dialect),\n# and 2.0.45 fixed SQLite reflection of multiple CHECK constraints, so 2.0.45 is\n# the oldest release the dialects fully work on. This guard must run before\n# importing .dialect, which fails on releases before 2.0.42 with an ImportError\n# about SQLAlchemy internals instead of a clear message.\n_MIN_SQLALCHEMY_VERSION = (2, 0, 45)\n\nif tuple(int(n) for n in re.findall(r\"\\d+\", sqlalchemy.__version__)[:3]) < _MIN_SQLALCHEMY_VERSION:\n    raise ImportError(\n        f\"pyturso's SQLAlchemy dialects require SQLAlchemy >= 2.0.45 \"\n        f\"(found {sqlalchemy.__version__}). Upgrade with: pip install 'sqlalchemy>=2.0.45'\"\n    )\n\nfrom .dialect import (  # noqa: E402\n    AioTursoDialect,\n    TursoDialect,\n    TursoSyncDialect,\n    get_sync_connection,\n)\n\n__all__ = [\n    \"AioTursoDialect\",\n    \"TursoDialect\",\n    \"TursoSyncDialect\",\n    \"get_sync_connection\",\n]\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/python/turso/sqlalchemy/__init__.py#L27-L63","documentation":"Importing turso.sqlalchemy compares the installed SQLAlchemy version against a minimum of 2.0.45 and raises ImportError with an upgrade hint when it is older. The floor exists because 2.0.42 first shipped AsyncAdapt_dbapi_module (imported by the dialect module) and 2.0.45 fixed SQLite reflection of multiple CHECK constraints. Without the guard, older releases die with a confusing ImportError about SQLAlchemy internals.","triggerScenarios":"import turso.sqlalchemy or use the sqlite+turso:// dialect with sqlalchemy < 2.0.45 installed; a lockfile pinning sqlalchemy==2.0.36; another dependency's constraint forcing a downgrade below 2.0.45.","commonSituations":"Fresh clone of a project with stale requirements.txt; poetry/pipenv locks not updated after adding pyturso; CI layer caches holding an old sqlalchemy wheel; system packages shipping old SQLAlchemy.","solutions":["Install the required version: pip install 'sqlalchemy>=2.0.45'","Update the lockfile or requirements line and recreate the environment","Verify with: python -c \"import sqlalchemy; print(sqlalchemy.__version__)\""],"exampleFix":"# before (requirements.txt)\nsqlalchemy==2.0.36\n\n# after\nsqlalchemy>=2.0.45","handlingStrategy":"validation","validationCode":"import re\nimport sqlalchemy\n\ndef sqlalchemy_supported() -> bool:\n    nums = tuple(int(n) for n in re.findall(r\"\\d+\", sqlalchemy.__version__)[:3])\n    return nums >= (2, 0, 45)\n\nif not sqlalchemy_supported():\n    raise RuntimeError(\"Upgrade first: pip install 'sqlalchemy>=2.0.45'\")\nimport turso.sqlalchemy","typeGuard":null,"tryCatchPattern":"try:\n    import turso.sqlalchemy\nexcept ImportError as e:\n    if \"SQLAlchemy >= 2.0.45\" in str(e):\n        raise SystemExit(\"Run: pip install 'sqlalchemy>=2.0.45'\") from e\n    raise","preventionTips":["Pin 'sqlalchemy>=2.0.45' in the same requirements set as pyturso","Run pip check after environment changes to catch downgrades","Gate dialect imports behind a startup version check in deploy scripts"],"tags":["python","sqlalchemy","version","import-error","dependencies"],"backgroundTag":"dependency-version-mismatch","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}