---
title: "SQLAlchemy Tracing"
description: "Trace SQLAlchemy database spans with Judgment."
sidebar:
  label: "SQLAlchemy"
seo:
  title: "SQLAlchemy Tracing with Judgment | Integration Docs"
  description: "Trace SQLAlchemy spans with Judgment to connect application behavior to production AI agent monitoring and evaluation."
---

SQLAlchemy tracing uses the standard OpenTelemetry SQLAlchemy instrumentation
and routes database spans through Judgment.

{/* @test-flow
  id: tracing-db-sqlalchemy
  lang: python
  env: JUDGMENT_API_KEY, JUDGMENT_ORG_ID
*/}

**uv**

```bash
uv add judgeval sqlalchemy opentelemetry-instrumentation-sqlalchemy
```

**pip**

```bash
pip install judgeval sqlalchemy opentelemetry-instrumentation-sqlalchemy
```

```python title="sqlalchemy_tracing.py"
from judgeval import Tracer
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
from sqlalchemy import create_engine, text

Tracer.init(project_name="sqlalchemy_app")

engine = create_engine("sqlite:///:memory:")
SQLAlchemyInstrumentor().instrument(engine=engine)

with engine.connect() as connection:
    connection.execute(text("select 1"))

Tracer.force_flush()
```
