/sql-database-pipeline:create-sql-database-pipeline [database-url-or-description] [destination]from sql-database-pipeline
Creates a dlt pipeline to load tables from SQL databases (Postgres, MySQL, MSSQL, Oracle, SQLite) to destinations like DuckDB, BigQuery, or Snowflake. Handles credentials, driver selection, and incremental loading.
Ships in sql-database-pipeline. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Build the simplest working pipeline — one table, no incremental loading — to get data flowing fast.
Docs: https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database
Parse $ARGUMENTS:
database (required): description of the source database (e.g. "postgres on localhost", "Rfam MySQL", a connection URL, or just the DB type)destination (optional, default duckdb): where to load dataAsk the user: how much data will be loaded? (approximate row count or table size is enough)
Note the answer — it will be used in step 11 to recommend the right backend and chunk_size.
Key rules regardless of scale:
table_names= to sql_database() — avoids reflecting the entire schemaRun ls -la to see the current state before scaffolding.
uv run dlthub --non-interactive pipeline init sql_database <destination>
Note: --non-interactive is a global flag on dlthub and may appear at any position in the command. Always pass it to prevent prompts that block execution.
If the command fails with invalid choice: 'pipeline', the dlthub workspace is not initialized. Run uv run dlthub init and follow its instructions — most importantly run uv sync to pull required dependencies — then retry.
This creates:
sql_database_pipeline.py — working example.dlt/secrets.toml — credentials template.dlt/config.toml — pipeline configrequirements.txt, .gitignoreRun ls -la again to confirm what was created.
Do these in parallel:
Read essential dlt docs upfront:
https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database (setup steps: https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database/setup.md)https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database/configuration.mdhttps://dlthub.com/docs/general-usage/credentials/setup.mdIdentify the driver:
Different databases need different SQLAlchemy dialect + driver packages:
| Database | drivername | extra package |
|---|---|---|
| PostgreSQL | postgresql+psycopg2 | psycopg2-binary |
| MySQL / MariaDB | mysql+pymysql | pymysql |
| MS SQL Server | mssql+pyodbc | pyodbc |
| Oracle | oracle+cx_oracle | cx_Oracle |
| SQLite | sqlite | (built-in) |
Install the driver + sql_database extras if missing:
uv add "dlt[hub,sql_database]" <driver-package>
Read the following (do NOT read secrets.toml):
sql_database_pipeline.py — read for scaffold patterns, then replace its contents with the real pipeline in step 6.dlt/config.toml — pipeline config structureReplace the scaffold — write the real pipeline into the generated sql_database_pipeline.py, or rename the file to match the use case (e.g. movies_pipeline.py). Either way: do not create a second file alongside the scaffold. The scaffold has no further purpose once replaced.
Choose one scenario based on how many tables to load:
sql_tableimport dlt
from dlt.sources.sql_database import sql_table
def main() -> None:
pipeline = dlt.pipeline(
pipeline_name="<name>",
destination="<destination>",
dataset_name="<name>",
dev_mode=True, # fresh timestamped dataset on each run
progress="log", # NOTE: progress goes on dlt.pipeline(), NOT on pipeline.run()
)
table = sql_table(
table="<table_name>",
chunk_size=500,
# schema="<schema>", # set if not the default schema
)
load_info = pipeline.run(table.add_limit(1), write_disposition="replace")
print(load_info)
if __name__ == "__main__":
main()
sql_databaseimport dlt
from dlt.sources.sql_database import sql_database
def main() -> None:
pipeline = dlt.pipeline(
pipeline_name="<name>",
destination="<destination>",
dataset_name="<name>",
dev_mode=True,
progress="log",
)
source = sql_database(
schema="<schema>", # set if not the default schema
table_names=["<t1>", "<t2>"], # always pass table_names — avoids full-schema reflection
chunk_size=500,
)
load_info = pipeline.run(source.add_limit(1), write_disposition="replace")
print(load_info)
if __name__ == "__main__":
main()
Key rules:
progress="log" belongs on dlt.pipeline(), not on pipeline.run() — that parameter does not exist on run()dev_mode=True creates a new timestamped dataset on every run — keeps test runs non-destructive.add_limit(1) loads one chunk only — always use for first/test runstable_names= to sql_database() — omitting it reflects the entire schema, which is slow and loads unwanted tables.dlt/secrets.tomlUsing the reflection level chosen in find-sql-database-source, set it on the source:
# Scenario A
table = sql_table(table="<table_name>", chunk_size=500, reflection_level="full")
# Scenario B
source = sql_database(table_names=[...], chunk_size=500, reflection_level="full")
minimal — column names and nullability only; types inferred from data. Use when full causes casting errors.full — column names, nullability, and data types including decimal precision/scale. Default; works for most cases.full_with_precision — maximum detail including precision for text/binary. Use when the destination requires strict typing; may cause type-mismatch errors.Ref: https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database/advanced#column-reflection
If the user needs to transform data before or during loading, introduce the right tool depending on when the transformation happens:
Filter rows at SQL level — query_adapter_callback:
def query_adapter(query, table):
if table.name == "orders":
return query.where(table.c.status == "active")
return query
source = sql_database(query_adapter_callback=query_adapter)
Add or modify columns at schema level — table_adapter_callback to append computed columns before extraction.
Transform rows after extraction — add_map on a resource:
def pseudonymize(row):
row["email"] = hash(row["email"])
return row
source.orders.add_map(pseudonymize)
Ref: https://dlthub.com/docs/dlt-ecosystem/verified-sources/sql_database/usage
If no transformation is needed, skip this step.
Boundary: these callbacks are for extraction-time transforms — filtering, masking, or reshaping data before it hits the destination. For post-load modeling (Kimball dimensions, CDM, cross-source joins) hand off to the transformations toolkit instead.
Config (non-secret values like schema name, table name):
Edit .dlt/config.toml directly:
# .dlt/config.toml
[sources.sql_database]
table_name = "<table>"
Secrets (credentials): never read or write secrets.toml directly.
Present this template to the user and ask them to fill it in. Use secrets_update_fragment MCP tool (or dlthub ai secrets CLI) to write the fragment — do not edit the file directly:
# .dlt/secrets.toml
[sources.sql_database.credentials]
drivername = "<dialect+driver>" # e.g. mysql+pymysql, postgresql+psycopg2
host = "<host>"
port = <port>
username = "<username>"
password = "<password>"
database = "<database>"
A connection string is also accepted:
[sources.sql_database.credentials]
credentials = "<dialect+driver>://user:password@host:port/database"
ALWAYS Get Feedback before running for the first time. Show a summary of the files you changed or created, and confirm the user has filled in credentials.
When user is ready, run:
uv run python <pipeline_script>.py
Expected output shows extract/normalize/load steps with row counts and timing from progress="log".
When errors occur, use debug-sql-database-pipeline to diagnose — do not add more complexity first.
Common first-run errors:
ConfigFieldMissingException — a credentials field is missing or misnamed in secrets.tomlOperationalError / Can't connect — wrong host/port/credentials or DB unreachableModuleNotFoundError: No module named 'sqlalchemy' — run uv add "dlt[hub,sql_database]"MissingDependencyException: numpy required — the pyarrow backend also needs numpy: uv add numpySize the table (row count × row width) and compare it with the runner's RAM. Then pick:
sqlalchemy (default)pyarrow (needs numpy), chunk_size 5,000–50,000connectorxFor trade-offs, sizing and out-of-memory fixes, see "Faster backend" in optimize-sql-performance.
Apply the chosen backend:
table = sql_table(table="<table_name>", chunk_size=500, backend="pyarrow")
Re-run the test to confirm the backend works before moving on.
Note: When using
pyarrow,pandas, orconnectorx(normalization skipped),apply_hintsworks for incremental loading, write disposition, merge keys, etc. — but schema changes likecolumns={...}do not work. Usetable_adapter_callbackfor column-level schema changes instead.
adjust-table to remove limits and add incremental loading for productiondebug-sql-database-pipeline to inspect traces and load packagesadd-table to add resources to the pipelineWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
PostgreSQL, MySQL, SQLite, DuckDB, BigQuery, Snowflake, SQLAlchemy, Python
npx claudepluginhub dlt-hub/dlthub-ai-harness --plugin sql-database-pipeline8 skills in this plugin
/add-tableAdd a new table or view to an existing dlt SQL database pipeline. Use when the user wants to load additional tables from the same database that already has a working pipeline./adjust-tableAdjust a working dlt SQL database pipeline for production — remove dev limits, add incremental loading, configure merge keys. Use when the user wants to remove .add_limit(), load the full table, or set up incremental loading on a cursor column. For speed/memory tuning (backend, chunk size, parallelism) use optimize-sql-performance instead. For inspecting loaded data or fixing column types/schema after a load, use validate-sql-database-data instead./debug-sql-database-pipelineDebug and inspect a dlt SQL database pipeline after running it. Use after a pipeline run (success or failure) to inspect traces, load packages, schema, and diagnose errors like connection failures, missing credentials, driver issues, or failed load jobs./find-sql-database-sourceFind and explore a SQL database source for a dlt pipeline. Use when the user wants to load data from a relational database (postgres, mysql, mssql, oracle, sqlite, or any SQLAlchemy-supported database), mentions a database connection, wants to discover available tables, or asks to build a pipeline from a SQL source./optimize-sql-performanceSpeed up a dlt SQL database pipeline. Use when extraction from a relational database (postgres, mysql, mssql, oracle, snowflake, etc.) is slow or memory-heavy and the user wants to optimize it — pick a faster backend, tune chunk size, parallelize tables, or reduce reflection overhead. For first-time incremental/merge setup or removing .add_limit() use adjust-table instead./validate-sql-database-dataValidate schema and data after a successful dlt SQL database pipeline load. Use when the user wants to check if loaded data looks correct, inspect table schemas, fix data types, or verify column mappings from the source database.Other plugins' skills for the same job