Load Gerrit Code Review data to DuckDB
Build a Gerrit Code Review to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Gerrit Code Review API base URL, auth, endpoints, and incremental loading.
Gerrit Code Review is a web-based code review system for Git projects that provides a REST API for automated tooling and scripting. Everything needed to build a working Gerrit Code Review → DuckDB pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your Gerrit Code Review to DuckDB pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
PromptRunuvx dlthub-init@latestto build a pipeline from Gerrit Code Review to DuckDB and run it on dltHub
That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Gerrit Code Review API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
Gerrit Code Review API at a glance
| Base URL | https://<gerrit-host>/ (API endpoints are accessed under this host) |
| Example endpoint | GET changes/ |
| Authentication | supports HTTP Basic authentication via '/a/' prefix or 'access_token' URL parameter — sent in the Authorization header, prefixed Basic |
| Pagination | Offset-based |
| Incremental field | next-page-token |
| Record id | _number |
| API reference | https://gerrit-review.googlesource.com/Documentation/rest-api.html |
These values come from the Gerrit Code Review API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Gerrit Code Review API?
Gerrit supports HTTP Basic authentication, typically by prefixing the URL path with '/a/'. Alternatively, an 'access_token' can be passed as a query parameter in the URL. For certain mutations, an 'X-Gerrit-Auth' header containing an XSRF token may be required.
1. Get your credentials
To obtain credentials for the Gerrit REST API, navigate to your Gerrit instance and click on your user profile/avatar in the upper-right corner. Select 'Settings' from the menu. Within the settings dashboard, look for a section labeled 'HTTP Credentials' or 'Password'. Click the button to 'Generate' or 'Create' a new HTTP password (also referred to as an API key). Note your username and the generated password, as these will be used for Basic Authentication. Authentication requires prefixing API endpoint URLs with '/a/' to trigger this authentication mode.
2. Add them to .dlt/secrets.toml
[sources.gerrit_code_review_source] auth = "REPLACE_ME"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What Gerrit Code Review data can I load into DuckDB?
These are the Gerrit Code Review endpoints dlt can load into DuckDB:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| changes | /changes/ | GET | Queries changes visible to the caller. | |
| projects | /projects/ | GET | Lists projects visible to the caller. | |
| groups | /groups/ | GET | Lists groups visible to the caller. | |
| accounts | /accounts/ | GET | Lists accounts visible to the caller. | |
| plugins | /plugins/ | GET | Lists installed plugins. |
How do I load only new Gerrit Code Review records?
Gerrit Code Review exposes next-page-token on changes/, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.
{"name": "changes", "endpoint": { "path": "changes/", "incremental": {"cursor_path": "next-page-token", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated Gerrit Code Review pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading /changes/ and /projects/ from the Gerrit Code Review API into DuckDB:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def gerrit_code_review_source(auth=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://<gerrit-host>/ (API endpoints are accessed under this host)", "auth": {"type": "http_basic", "username": "REPLACE_ME", "password": auth}, }, "resources": [ {"name": "changes", "endpoint": {"path": "changes/"}}, {"name": "projects", "endpoint": {"path": "projects/"}} ], } yield from rest_api_resources(config) def load_gerrit_code_review_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="gerrit_code_review_pipeline", destination="duckdb", dataset_name="gerrit_code_review_data", ) load_info = pipeline.run(gerrit_code_review_source()) print(load_info) if __name__ == "__main__": load_gerrit_code_review_to_duckdb()
Run it with python gerrit_code_review_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query Gerrit Code Review data in DuckDB?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("gerrit_code_review_pipeline").dataset() df = data.changes.df() print(df.head())
SQL:
SELECT * FROM gerrit_code_review_data.changes LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Gerrit Code Review to DuckDB pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw Gerrit Code Review loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load Gerrit Code Review data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for Gerrit Code Review to DuckDB?
Request dlt skills, commands, AGENT.md files, and AI-native context.