Skip to content

Add command-line interface (closes #44) - #68

Merged
jedymatt merged 1 commit into
mainfrom
cli-support
Jul 4, 2026
Merged

Add command-line interface (closes #44)#68
jedymatt merged 1 commit into
mainfrom
cli-support

Conversation

@jedymatt

@jedymatt jedymatt commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Adds a sqlalchemyseed CLI so a database can be seeded from data files without writing Python — the first feature from the revival roadmap (#65). Closes #44.

Usage

sqlalchemyseed data.json --url sqlite:///app.db
sqlalchemyseed seeds/ --url "$DATABASE_URL"          # directory of json/yaml
sqlalchemyseed a.json b.yaml --url sqlite:///app.db  # multiple files
python -m sqlalchemyseed data.json --url sqlite:///app.db

What's included

  • Console script ([project.scripts]) and python -m sqlalchemyseed via __main__.py
  • One or more files and/or directories (a directory seeds every .json/.yaml/.yml, sorted)
  • DB URL from --url or the DATABASE_URL env var
  • --dry-run (seed in a transaction, then roll back), --seeder basic|hybrid, --ref-prefix
  • CSV support via --model (CSV isn't self-describing)
  • Inserts the working directory on sys.path so model paths like models.Person resolve against the user's project
  • All files seed in a single transaction — commit once, or roll back as a unit on error

Implementation is a thin, dependency-free (argparse) wrapper over the existing loaders + Seeder/HybridSeeder; no changes to the core engine.

Tests & verification

  • 12 new CLI tests (each format, directories, multiple paths, dry-run, hybrid, env-var URL, and error paths) — 71 tests pass total
  • Driven end-to-end against a real external project: dry-run, real seed, python -m, $DATABASE_URL, and --help all behave correctly
  • uv build registers the sqlalchemyseed console script in the wheel

Bumps version to 2.2.0.

🤖 Generated with Claude Code

Add a `sqlalchemyseed` console script (and `python -m sqlalchemyseed`) that
seeds a database from data files without writing Python.

- Accepts one or more files and/or directories (directories seed every
  .json/.yaml/.yml inside, sorted)
- Database URL via --url or the DATABASE_URL env var
- --seeder basic|hybrid, --dry-run (seed then roll back), --ref-prefix
- CSV inputs supported via --model (CSV is not self-describing)
- Inserts the working directory on sys.path so model paths like
  "models.Person" resolve against the user's project

Bumps version to 2.2.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jedymatt
jedymatt merged commit 1c00e66 into main Jul 4, 2026
19 checks passed
@jedymatt
jedymatt deleted the cli-support branch July 4, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI support

1 participant