{"id":26843,"library":"cockroachdb","title":"CockroachDB SQLAlchemy Adapter","description":"CockroachDB adapter for SQLAlchemy, allowing SQLAlchemy applications to connect to CockroachDB. Current version 0.3.5. Release cadence is irregular; maintained by Cockroach Labs.","status":"active","version":"0.3.5","language":"python","source_language":"en","source_url":"https://github.com/cockroachdb/cockroachdb-python","tags":["cockroachdb","sqlalchemy","database","adapter"],"install":[{"cmd":"pip install cockroachdb","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for ORM and SQL connection","package":"sqlalchemy","optional":false}],"imports":[{"note":"","wrong":"","symbol":"cockroachdb","correct":"import cockroachdb"}],"quickstart":{"code":"from sqlalchemy import create_engine\nimport os\n\nDATABASE_URL = os.environ.get('DATABASE_URL', 'cockroachdb://user:password@localhost:26257/defaultdb?sslmode=disable')\nengine = create_engine(DATABASE_URL)\nwith engine.connect() as conn:\n    result = conn.execute(\"SELECT version()\")\n    print(result.fetchone())","lang":"python","description":"Create a SQLAlchemy engine for CockroachDB and run a simple query."},"warnings":[{"fix":"Use pip show to verify, or install in a clean environment.","message":"The package name 'cockroachdb' might conflict if you also have CockroachDB Python client installed (cockroachdb-python). This adapter is only for SQLAlchemy.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to version 0.3.5 and use 'cockroachdb://' scheme.","message":"Older versions (pre-0.3.0) used a different connection URI pattern. Ensure your URI starts with 'cockroachdb://' not 'cockroach://'.","severity":"deprecated","affected_versions":"< 0.3.0"},{"fix":"Use the 'run_transaction' helper from the CockroachDB Python client for proper retry support.","message":"Transactions with SERIALIZABLE isolation may behave differently than PostgreSQL. Use the cockroachdb-specific retry logic for transactions.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure your DATABASE_URL is correct and includes ?sslmode=disable or ?sslmode=require as needed.","cause":"Invalid connection string or missing SSL configuration.","error":"sqlalchemy.exc.OperationalError: (cockroachdb.sqlalchemy.dialect.CockroachDBDialect) ..."},{"fix":"Run 'pip install cockroachdb' in the correct Python environment.","cause":"The package is not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'cockroachdb'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}