Documentation

Everything you need to generate test data for MSSQL stored procedures — from the CLI or the API.

Overview

qseed generates INSERT statements for MSSQL stored procedures — automatically. Point it at your database and a stored procedure, and get test data back.

It connects to your MSSQL database locally, fetches all DDL needed by a stored procedure or query (the SP itself, referenced tables, views, and optionally sub-procedures), sends that DDL to the datagen API, and writes INSERT statements to stdout, a file, or your clipboard.

Credentials never leave your machine. Only DDL text is sent to the API.

QUICK START
qseed config set-api https://datagen.aldimhr.dev
qseed config add default
qseed --procedure GetCustomerOrders --rows 10

CLI Reference

qseed connects to your MSSQL database, fetches stored procedure DDL (including referenced tables, views, and sub-procedures), and sends it to the datagen API for generation. Your credentials never leave your machine.

Installation

Requires Python 3.10+ and pymssql.

$ pip install qseed

Ubuntu/Raspberry Pi: apt install python3-dev freetds-dev libssl-dev first.
macOS: brew install freetds first.

Configuration

Add a connection profile. Passwords stored in OS keyring. All settings can be overridden via environment variables.

$ qseed config set-api https://datagen.aldimhr.dev
$ qseed config add default
# Interactive: Server, Port [1433], Database, User

Commands

run

Generate INSERT statements from a stored procedure or SQL query. Supports --recursive for procedure chains. This is the default command.

list

List available stored procedures. Supports --schema, --search TEXT, and --json output.

config

Manage connection profiles (add, list, show, test, remove, set-default, set-api).

version

Print the qseed version.

run — source (one required)

--procedure NAME Stored procedure name to fetch and analyze
--sql TEXT Raw SQL string to generate data for
--sql-file PATH Path to a .sql file

run — connection & generation options

--server HOST MSSQL server hostname or IP (overrides profile)
--port PORT Port (default: 1433)
--database DB Database name
--user USER SQL Server login
--password PASS Password
--password-env VAR Read password from environment variable
--profile NAME Use a saved connection profile (default: "default")
-r, --rows N Target row count per procedure (default: 10)
-p, --param @N=V Parameter binding — repeatable, passed to all procedures in chain
--schema SCHEMA Schema for object lookup (default: dbo)

run — Recursive Mode

When a stored procedure calls other stored procedures via EXEC, use --recursive to process the full chain via BFS. Each procedure gets its own API call with computed PK offsets to prevent collisions. The same -p parameters are passed to every procedure in the chain.

--recursive Process the full procedure chain (BFS, cycle-safe) --max-depth N Max chain depth (default: 5) --offset-multiplier N PK offset multiplier (default: 10) --no-sub-proc-warning Suppress sub-procedure detection warning

run — output & debug options

-o, --output PATH Write to file (default: stdout)
--copy Copy output to clipboard
--open Open in $DATAGEN_EDITOR or $EDITOR
--dry-run Fetch and print DDL without calling the API
--show-ddl Print fetched DDL alongside INSERT output
--timeout N DB connection timeout in seconds (default: 30)
--api-timeout N API call timeout in seconds (default: 120)

Examples

SINGLE PROCEDURE
$ qseed --procedure GetCustomerOrders --rows 10
WITH PARAMETERS
$ qseed \
--procedure GetCustomerOrders \
--rows 10 \
-p @CustomerId=5 \
-o test_data.sql
                        
DRY RUN (INSPECT DDL) $ qseed --procedure Orders --dry-run
COPY TO CLIPBOARD $ qseed --procedure Orders --copy

API Reference

The datagen API generates INSERT statements from stored procedure DDL, table schemas, and optionally view DDL. No live database connection needed — send DDL as text.

Endpoint

POST https://datagen.aldimhr.dev/generate

Accepts JSON body. Returns plain text SQL.

Request Body

FIELD TYPE REQUIRED DESCRIPTION
sql string required Stored procedure DDL or raw SQL query
tables string required CREATE TABLE DDL (one or more tables)
views string optional CREATE VIEW DDL (if procedure references views)
rows integer optional Target row count (default: 10, max: 1000)
params array optional Parameter bindings, e.g. ["@Status=ACTIVE"]
pk_start_offset integer optional PK sequence start offset (default: 0, used by recursive mode)
no_transaction boolean optional Skip BEGIN/COMMIT transaction wrapper

Example

curl -X POST https://datagen.aldimhr.dev/generate \
  -H "Content-Type: application/json" \
  -d '{
    "sql": "CREATE PROCEDURE GetOrdersByStatus @Status VARCHAR(20) AS ...",
    "tables": "CREATE TABLE Orders (OrderId INT PRIMARY KEY, Status VARCHAR(20), ...)",
    "views": "CREATE VIEW vw_ActiveOrders AS SELECT ...",
    "rows": 10,
    "params": ["@Status=ACTIVE"],
    "pk_start_offset": 0
  }'

Environment Variables

All settings can be overridden via environment variables. Useful for CI/CD — no config file needed. Env vars take priority over config file; CLI flags take priority over env vars.

ENV VAR CONFIG EQUIVALENT
QSEED_API_URL api_url
QSEED_SERVER profiles.default.server
QSEED_PORT profiles.default.port
QSEED_DATABASE profiles.default.database
QSEED_USER profiles.default.user
QSEED_PASSWORD profiles.default.password
QSEED_SCHEMA profiles.default.schema