Skip to content

Installation

Requirements

  • Python 3.10 or higher
  • CockroachDB 24.2 or higher (for native vector support)

Install from PyPI

pip install langchain-cockroachdb

Or with uv (recommended):

uv pip install langchain-cockroachdb

Install from Source

git clone https://github.com/cockroachdb/langchain-cockroachdb.git
cd langchain-cockroachdb
pip install -e .

Development Installation

For contributing or development:

git clone https://github.com/cockroachdb/langchain-cockroachdb.git
cd langchain-cockroachdb
pip install -e ".[dev]"

This installs additional dependencies: - pytest (testing) - pytest-asyncio (async testing) - ruff (linting/formatting) - mypy (type checking) - testcontainers (integration testing)

CockroachDB Setup

  1. Sign up at cockroachlabs.cloud
  2. Create a free cluster
  3. Get your connection string
  4. Download the SSL certificate

Option 2: Docker (Development)

docker run -d \
  --name cockroachdb \
  -p 26257:26257 \
  -p 8080:8080 \
  cockroachdb/cockroach:latest \
  start-single-node --insecure

Option 3: Local Binary

Download from cockroachlabs.com/docs/releases

cockroach start-single-node --insecure --listen-addr=localhost:26257

Verify Installation

import asyncio
from langchain_cockroachdb import CockroachDBEngine

async def test():
    engine = CockroachDBEngine.from_connection_string(
        "cockroachdb://root@localhost:26257/defaultdb?sslmode=disable"
    )
    async with engine.engine.connect() as conn:
        from sqlalchemy import text
        result = await conn.execute(text("SELECT version()"))
        print(f"✅ Connected: {result.scalar()}")
    await engine.aclose()

asyncio.run(test())

Next Steps