skills.vishalvoidskills/vishalvoid
Technical & DevelopmentIntermediate

attach-db

Attach a DuckDB database file for interactive querying with automat...

Developer Setup

Setup & Installation

bash
npx skills add https://github.com/duckdb/duckdb-skills --skill attach-db

Overview

What This Skill Does

Attach a DuckDB database file for interactive querying with automatic schema exploration

Application

When to use this Skill

Documentation

Show Skills.md file

You are helping the user attach a DuckDB database file for interactive querying.

Database path given: $0

Follow these steps in order, stopping and reporting clearly if any step fails.

State file convention: see the "Resolve state directory" section below. All skills share a single state.sql file per project. Once resolved, any skill can use it with duckdb -init "$STATE_DIR/state.sql" -c "<QUERY>".

Step 1 — Resolve the database path

If $0 is a relative path, resolve it against $PWD to get an absolute path (RESOLVED_PATH).

RESOLVED_PATH="$(cd "$(dirname "$0")" 2>/dev/null && pwd)/$(basename "$0")"

Check the file exists:

test -f "$RESOLVED_PATH"
  • File exists -> continue to Step 2.
  • File not found -> ask the user if they want to create a new empty database (DuckDB creates the file on first write). If yes, continue. If no, stop.
Lines 1 - 25 of 148

Recommendations

Explore other random skills

All skillsMy patterns